Skip to content

Commit 7a8d695

Browse files
author
Mauren Berti
committed
Convert to multi-stage Dockerfile.
- Remove architecture-specific Dockerfile and Makefile target. - Convert Dockerfile to a multi-stage build, keeping only what is needed to run.
1 parent e7b1ef7 commit 7a8d695

File tree

4 files changed

+20
-53
lines changed

4 files changed

+20
-53
lines changed

Dockerfile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,42 @@
44
# change is that the Hugo version is now an overridable argument rather than a fixed
55
# environment variable.
66

7-
FROM golang:1.15-alpine
7+
FROM golang:1.16-alpine
88

99
LABEL maintainer="Luc Perkins <[email protected]>"
1010

1111
RUN apk add --no-cache \
1212
curl \
13+
gcc \
14+
g++ \
15+
musl-dev \
16+
build-base \
17+
libc6-compat
18+
19+
ARG HUGO_VERSION
20+
21+
RUN mkdir $HOME/src && \
22+
cd $HOME/src && \
23+
curl -L https://github.com/gohugoio/hugo/archive/refs/tags/v${HUGO_VERSION}.tar.gz | tar -xz && \
24+
cd "hugo-${HUGO_VERSION}" && \
25+
go install --tags extended
26+
27+
FROM golang:1.16-alpine
28+
29+
RUN apk add --no-cache \
1330
git \
1431
openssh-client \
1532
rsync \
16-
build-base \
17-
libc6-compat \
1833
npm && \
1934
npm install -D autoprefixer postcss-cli
2035

21-
ARG HUGO_VERSION
22-
2336
RUN mkdir -p /usr/local/src && \
2437
cd /usr/local/src && \
25-
curl -L https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz | tar -xz && \
26-
mv hugo /usr/local/bin/hugo && \
2738
addgroup -Sg 1000 hugo && \
2839
adduser -Sg hugo -u 1000 -h /src hugo
2940

41+
COPY --from=0 /go/bin/hugo /usr/local/bin/hugo
42+
3043
WORKDIR /src
3144

3245
USER hugo:hugo

Dockerfile.arm64

Lines changed: 0 additions & 37 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ 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-
8174
container-build: module-check
8275
$(CONTAINER_RUN) --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 $(CONTAINER_IMAGE) sh -c "npm ci && hugo --minify --environment development"
8376

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ 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-
5048
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.
5149

5250
## Running the website locally using Hugo

0 commit comments

Comments
 (0)