Skip to content

Commit 75f72ca

Browse files
authored
Merge pull request #21136 from dvdksn/use-official-hugo-image
ci: use official Hugo image
2 parents 970eb66 + 5b8ceb6 commit 75f72ca

File tree

4 files changed

+19
-36
lines changed

4 files changed

+19
-36
lines changed

Dockerfile

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,27 @@ ARG ALPINE_VERSION=3.20
77
ARG GO_VERSION=1.23
88
# HTMLTEST_VERSION sets the wjdp/htmltest version for HTML testing
99
ARG HTMLTEST_VERSION=0.17.0
10+
# HUGO_VERSION sets the version of Hugo to build the site with
11+
ARG HUGO_VERSION=0.136.0
1012

11-
# base is the base stage with build dependencies
12-
FROM golang:${GO_VERSION}-alpine AS base
13-
WORKDIR /src
14-
RUN apk --update add nodejs npm git gcompat
15-
16-
# node installs Node.js dependencies
17-
FROM base AS node
18-
COPY package*.json .
19-
ENV NODE_ENV=production
20-
RUN npm install
21-
22-
# hugo downloads and extracts the Hugo binary
23-
FROM base AS hugo
24-
ARG HUGO_VERSION=0.134.3
25-
ARG TARGETARCH
26-
WORKDIR /tmp/hugo
27-
RUN wget -O "hugo.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz"
28-
RUN tar -xf "hugo.tar.gz" hugo
29-
30-
# build-base is the base stage for building the site
31-
FROM base AS build-base
32-
COPY --from=hugo /tmp/hugo/hugo /bin/hugo
33-
COPY --from=node /src/node_modules /src/node_modules
13+
# build-base is the base stage used for building the site
14+
FROM ghcr.io/gohugoio/hugo:v${HUGO_VERSION} AS build-base
15+
USER root
16+
ENV NODE_ENV="production"
17+
RUN --mount=source=package.json,target=package.json \
18+
--mount=source=package-lock.json,target=package-lock.json \
19+
--mount=type=cache,target=/root/.npm \
20+
npm ci
3421
COPY . .
3522

36-
# dev is for local development with Docker Compose
37-
FROM build-base AS dev
38-
3923
# build creates production builds with Hugo
4024
FROM build-base AS build
4125
# HUGO_ENV sets the hugo.Environment (production, development, preview)
42-
ARG HUGO_ENV
26+
ARG HUGO_ENV="development"
4327
# DOCS_URL sets the base URL for the site
44-
ARG DOCS_URL
45-
RUN hugo --gc --minify -d /out -e $HUGO_ENV -b $DOCS_URL
28+
ARG DOCS_URL="https://docs.docker.com"
29+
RUN --mount=type=cache,target=/cache \
30+
hugo --gc --minify -d /out -e $HUGO_ENV -b $DOCS_URL
4631

4732
# lint lints markdown files
4833
FROM davidanson/markdownlint-cli2:v0.14.0 AS lint
@@ -122,7 +107,7 @@ fi
122107
EOT
123108

124109
# pagefind installs the Pagefind runtime
125-
FROM base AS pagefind
110+
FROM node:alpine${ALPINE_VERSION} AS pagefind
126111
ARG PAGEFIND_VERSION=1.1.1
127112
COPY --from=build /out ./public
128113
RUN --mount=type=bind,src=pagefind.yml,target=pagefind.yml \

compose.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
server:
33
build:
44
context: .
5-
target: dev
5+
target: build-base
66
ports:
77
- "1313:1313"
88
entrypoint: ["hugo", "server", "--bind", "0.0.0.0"]
@@ -11,5 +11,3 @@ services:
1111
- action: sync
1212
path: .
1313
target: /src
14-
ignore:
15-
- node_modules/

docker-bake.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
variable "HUGO_ENV" {
2-
default = "development"
2+
default = null
33
}
44

55
variable "DOCS_URL" {
6-
default = "https://docs.docker.com"
6+
default = null
77
}
88

99
variable "DOCS_SITE_DIR" {

netlify.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ publish = "public"
44
[context.deploy-preview.environment]
55
NODE_VERSION = "20"
66
NODE_ENV = "production"
7-
HUGO_VERSION = "0.134.3"
7+
HUGO_VERSION = "0.136.0"
88
HUGO_ENABLEGITINFO = "true"
99
HUGO_ENVIRONMENT = "preview"
1010

0 commit comments

Comments
 (0)