Skip to content

Commit 19ece13

Browse files
authored
Merge pull request #21298 from dvdksn/hugo-custom-docker-base
ci: custom hugo setup + dependency updates
2 parents 241d748 + c643508 commit 19ece13

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

Dockerfile

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
11
# syntax=docker/dockerfile:1
22
# check=skip=InvalidBaseImagePlatform
33

4-
# ALPINE_VERSION sets the Alpine Linux version for all Alpine stages
54
ARG ALPINE_VERSION=3.20
6-
# GO_VERSION sets the Go version for the base stage
75
ARG GO_VERSION=1.23
8-
# HTMLTEST_VERSION sets the wjdp/htmltest version for HTML testing
96
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.3
7+
ARG HUGO_VERSION=0.136.5
8+
ARG NODE_VERSION=22
9+
ARG PAGEFIND_VERSION=1.1.1
1210

13-
# build-base is the base stage used for building the site
14-
FROM ghcr.io/gohugoio/hugo:v${HUGO_VERSION} AS build-base
11+
# base defines the generic base stage
12+
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
13+
RUN apk add --no-cache \
14+
git \
15+
nodejs \
16+
npm \
17+
gcompat
18+
19+
# npm downloads Node.js dependencies
20+
FROM base AS npm
1521
ENV NODE_ENV="production"
22+
WORKDIR /out
1623
RUN --mount=source=package.json,target=package.json \
1724
--mount=source=package-lock.json,target=package-lock.json \
1825
--mount=type=cache,target=/root/.npm \
1926
npm ci
27+
28+
# hugo downloads the Hugo binary
29+
FROM base AS hugo
30+
ARG TARGETARCH
31+
ARG HUGO_VERSION
32+
WORKDIR /out
33+
ADD https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz .
34+
RUN tar xvf hugo_extended_${HUGO_VERSION}_linux-${TARGETARCH}.tar.gz
35+
36+
# build-base is the base stage used for building the site
37+
FROM base AS build-base
38+
WORKDIR /project
39+
COPY --from=hugo /out/hugo /bin/hugo
40+
COPY --from=npm /out/node_modules node_modules
2041
COPY . .
2142

2243
# build creates production builds with Hugo
@@ -25,7 +46,9 @@ FROM build-base AS build
2546
ARG HUGO_ENV="development"
2647
# DOCS_URL sets the base URL for the site
2748
ARG DOCS_URL="https://docs.docker.com"
28-
RUN hugo --gc --minify -e $HUGO_ENV -b $DOCS_URL
49+
ENV HUGO_CACHEDIR="/tmp/hugo_cache"
50+
RUN --mount=type=cache,target=/tmp/hugo_cache \
51+
hugo --gc --minify -e $HUGO_ENV -b $DOCS_URL
2952

3053
# lint lints markdown files
3154
FROM davidanson/markdownlint-cli2:v0.14.0 AS lint
@@ -105,8 +128,8 @@ fi
105128
EOT
106129

107130
# pagefind installs the Pagefind runtime
108-
FROM node:alpine${ALPINE_VERSION} AS pagefind
109-
ARG PAGEFIND_VERSION=1.1.1
131+
FROM base AS pagefind
132+
ARG PAGEFIND_VERSION
110133
COPY --from=build /project/public ./public
111134
RUN --mount=type=bind,src=pagefind.yml,target=pagefind.yml \
112135
npx pagefind@v${PAGEFIND_VERSION} --output-path "/pagefind"

netlify.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
publish = "public"
33

44
[context.deploy-preview.environment]
5-
NODE_VERSION = "20"
5+
NODE_VERSION = "22"
66
NODE_ENV = "production"
7-
HUGO_VERSION = "0.136.3"
7+
HUGO_VERSION = "0.136.5"
88
HUGO_ENABLEGITINFO = "true"
99
HUGO_ENVIRONMENT = "preview"
1010

0 commit comments

Comments
 (0)