Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.github
.gitignore
.idea
.hugo_build.lock
_releaser
CONTRIBUTING.md
Dockerfile
Expand Down
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ ARG GO_VERSION=1.23
# HTMLTEST_VERSION sets the wjdp/htmltest version for HTML testing
ARG HTMLTEST_VERSION=0.17.0
# HUGO_VERSION sets the version of Hugo to build the site with
ARG HUGO_VERSION=0.136.2
ARG HUGO_VERSION=0.136.3

# build-base is the base stage used for building the site
FROM ghcr.io/gohugoio/hugo:v${HUGO_VERSION} AS build-base
USER root
ENV NODE_ENV="production"
RUN --mount=source=package.json,target=package.json \
--mount=source=package-lock.json,target=package-lock.json \
Expand All @@ -26,8 +25,7 @@ FROM build-base AS build
ARG HUGO_ENV="development"
# DOCS_URL sets the base URL for the site
ARG DOCS_URL="https://docs.docker.com"
RUN --mount=type=cache,target=/cache \
hugo --gc --minify -d /out -e $HUGO_ENV -b $DOCS_URL
RUN hugo --gc --minify -e $HUGO_ENV -b $DOCS_URL

# lint lints markdown files
FROM davidanson/markdownlint-cli2:v0.14.0 AS lint
Expand All @@ -41,7 +39,7 @@ RUN --mount=type=bind,target=. \
# test validates HTML output and checks for broken links
FROM wjdp/htmltest:v${HTMLTEST_VERSION} AS test
WORKDIR /test
COPY --from=build /out ./public
COPY --from=build /project/public ./public
ADD .htmltest.yml .htmltest.yml
RUN htmltest

Expand Down Expand Up @@ -76,12 +74,12 @@ ARG UPSTREAM_REPO
ARG UPSTREAM_COMMIT
# HUGO_MODULE_REPLACEMENTS is the replacement module for the upstream project
ENV HUGO_MODULE_REPLACEMENTS="github.com/${UPSTREAM_MODULE_NAME} -> github.com/${UPSTREAM_REPO} ${UPSTREAM_COMMIT}"
RUN hugo --ignoreVendorPaths "github.com/${UPSTREAM_MODULE_NAME}" -d /out
RUN hugo --ignoreVendorPaths "github.com/${UPSTREAM_MODULE_NAME}"

# validate-upstream validates HTML output for upstream builds
FROM wjdp/htmltest:v${HTMLTEST_VERSION} AS validate-upstream
WORKDIR /test
COPY --from=build-upstream /out ./public
COPY --from=build-upstream /project/public ./public
ADD .htmltest.yml .htmltest.yml
RUN htmltest

Expand All @@ -96,9 +94,9 @@ EOT

# path-warnings checks for duplicate target paths
FROM build-base AS path-warnings
RUN hugo --printPathWarnings > /path-warnings.txt
RUN hugo --printPathWarnings > ./path-warnings.txt
RUN <<EOT
DUPLICATE_TARGETS=$(grep "Duplicate target paths" /path-warnings.txt)
DUPLICATE_TARGETS=$(grep "Duplicate target paths" ./path-warnings.txt)
if [ ! -z "$DUPLICATE_TARGETS" ]; then
echo "$DUPLICATE_TARGETS"
echo "You probably have a duplicate alias defined. Please check your aliases."
Expand All @@ -109,7 +107,7 @@ EOT
# pagefind installs the Pagefind runtime
FROM node:alpine${ALPINE_VERSION} AS pagefind
ARG PAGEFIND_VERSION=1.1.1
COPY --from=build /out ./public
COPY --from=build /project/public ./public
RUN --mount=type=bind,src=pagefind.yml,target=pagefind.yml \
npx pagefind@v${PAGEFIND_VERSION} --output-path "/pagefind"

Expand All @@ -121,13 +119,13 @@ COPY --from=pagefind /pagefind .
FROM alpine:${ALPINE_VERSION} AS test-go-redirects
WORKDIR /work
RUN apk add yq
COPY --from=build /out ./public
COPY --from=build /project/public ./public
RUN --mount=type=bind,target=. <<"EOT"
set -ex
./scripts/test_go_redirects.sh
EOT

# release is an empty scratch image with only compiled assets
FROM scratch AS release
COPY --from=build /out /
COPY --from=build /project/public /
COPY --from=pagefind /pagefind /pagefind
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish = "public"
[context.deploy-preview.environment]
NODE_VERSION = "20"
NODE_ENV = "production"
HUGO_VERSION = "0.136.2"
HUGO_VERSION = "0.136.3"
HUGO_ENABLEGITINFO = "true"
HUGO_ENVIRONMENT = "preview"

Expand Down
Loading