Skip to content

Commit e7b1ef7

Browse files
author
Mauren Berti
committed
Create Dockerfile for arm64 architecture.
1 parent 3668b41 commit e7b1ef7

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

Dockerfile.arm64

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This is a modified version of the original Dockerfile in this repository,
2+
# edited to install Hugo Extended from a tarball in a way that works with arm64
3+
# architectures.
4+
5+
FROM golang:1.16-alpine
6+
7+
RUN apk add --no-cache \
8+
curl \
9+
gcc \
10+
g++ \
11+
git \
12+
musl-dev \
13+
openssh-client \
14+
rsync \
15+
build-base \
16+
libc6-compat \
17+
npm && \
18+
npm install -D autoprefixer postcss-cli
19+
20+
ARG HUGO_VERSION
21+
22+
RUN mkdir $HOME/src && \
23+
cd $HOME/src && \
24+
curl -L https://github.com/gohugoio/hugo/archive/refs/tags/v${HUGO_VERSION}.tar.gz | tar -xz && \
25+
cd "hugo-${HUGO_VERSION}" && \
26+
go install --tags extended && \
27+
cp /go/bin/hugo /usr/local/bin/hugo && \
28+
mkdir -p /usr/local/src && \
29+
cd /usr/local/src && \
30+
addgroup -Sg 1000 hugo && \
31+
adduser -Sg hugo -u 1000 -h /src hugo
32+
33+
WORKDIR /src
34+
35+
USER hugo:hugo
36+
37+
EXPOSE 1313

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ container-image: ## Build a container image for the preview of the website
7171
--tag $(CONTAINER_IMAGE) \
7272
--build-arg HUGO_VERSION=$(HUGO_VERSION)
7373

74+
container-image-arm64: ## Build a container image for the preview of the website that works with arm64
75+
$(CONTAINER_ENGINE) build . \
76+
--file Dockerfile.arm64 \
77+
--network=host \
78+
--tag $(CONTAINER_IMAGE) \
79+
--build-arg HUGO_VERSION=$(HUGO_VERSION)
80+
7481
container-build: module-check
7582
$(CONTAINER_RUN) --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 $(CONTAINER_IMAGE) sh -c "npm ci && hugo --minify --environment development"
7683

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ make container-serve
4545

4646
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)).
4747

48+
If you use a computer with arm64 architecture instead of amd64, use the target `make container-image-arm64` instead to build the container image.
49+
4850
Open up your browser to <http://localhost:1313> to view the website. As you make changes to the source files, Hugo updates the website and forces a browser refresh.
4951

5052
## Running the website locally using Hugo

0 commit comments

Comments
 (0)