From e7b1ef7fda28f01acbaf3df10c47308e9bf61ed0 Mon Sep 17 00:00:00 2001 From: Mauren Berti Date: Fri, 18 Feb 2022 17:55:57 -0500 Subject: [PATCH] Create Dockerfile for arm64 architecture. --- Dockerfile.arm64 | 37 +++++++++++++++++++++++++++++++++++++ Makefile | 7 +++++++ README.md | 2 ++ 3 files changed, 46 insertions(+) create mode 100644 Dockerfile.arm64 diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 0000000000..49543bf091 --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,37 @@ +# This is a modified version of the original Dockerfile in this repository, +# edited to install Hugo Extended from a tarball in a way that works with arm64 +# architectures. + +FROM golang:1.16-alpine + +RUN apk add --no-cache \ + curl \ + gcc \ + g++ \ + git \ + musl-dev \ + openssh-client \ + rsync \ + build-base \ + libc6-compat \ + npm && \ + npm install -D autoprefixer postcss-cli + +ARG HUGO_VERSION + +RUN mkdir $HOME/src && \ + cd $HOME/src && \ + curl -L https://github.com/gohugoio/hugo/archive/refs/tags/v${HUGO_VERSION}.tar.gz | tar -xz && \ + cd "hugo-${HUGO_VERSION}" && \ + go install --tags extended && \ + cp /go/bin/hugo /usr/local/bin/hugo && \ + mkdir -p /usr/local/src && \ + cd /usr/local/src && \ + addgroup -Sg 1000 hugo && \ + adduser -Sg hugo -u 1000 -h /src hugo + +WORKDIR /src + +USER hugo:hugo + +EXPOSE 1313 diff --git a/Makefile b/Makefile index 57fca6e2d1..63ae35c778 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,13 @@ container-image: ## Build a container image for the preview of the website --tag $(CONTAINER_IMAGE) \ --build-arg HUGO_VERSION=$(HUGO_VERSION) +container-image-arm64: ## Build a container image for the preview of the website that works with arm64 + $(CONTAINER_ENGINE) build . \ + --file Dockerfile.arm64 \ + --network=host \ + --tag $(CONTAINER_IMAGE) \ + --build-arg HUGO_VERSION=$(HUGO_VERSION) + container-build: module-check $(CONTAINER_RUN) --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 $(CONTAINER_IMAGE) sh -c "npm ci && hugo --minify --environment development" diff --git a/README.md b/README.md index 87dd03e7eb..48650c569b 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ make container-serve If you see errors, it probably means that the hugo container did not have enough computing resources available. To solve it, increase the amount of allowed CPU and memory usage for Docker on your machine ([MacOSX](https://docs.docker.com/docker-for-mac/#resources) and [Windows](https://docs.docker.com/docker-for-windows/#resources)). +If you use a computer with arm64 architecture instead of amd64, use the target `make container-image-arm64` instead to build the container image. + Open up your browser to to view the website. As you make changes to the source files, Hugo updates the website and forces a browser refresh. ## Running the website locally using Hugo