Files
computer-playbook/roles/web-app-hugo/files/Dockerfile
kevinveenbirkenbachandClaude Opus 5.5 02354506e7 fix(web-app-hugo): build as the image's own user
The builder stage switched to root for everything, so npm lifecycle
scripts of the site's dependencies and the Hugo build ran as root.

The official image runs as hugo and ships Node and npm. Root now only
creates /src and /public for that user. npm install and the build run
as hugo, and the apk install of nodejs and npm is gone.

The README no longer repeats the pinned source tag, which the updater
moves in meta/services.yml only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 21:11:48 +02:00

42 lines
1.1 KiB
Docker

# Multi-stage Hugo build:
# Stage 1 (builder) runs Hugo against the cloned upstream content.
# Stage 2 (serve) ships the rendered /public/ via nginx.
# Both base-image refs are pinned via build args sourced from
# meta/services.yml and surface in the global image-drift report.
ARG HUGO_BUILDER_IMAGE
ARG HUGO_BUILDER_VERSION
ARG HUGO_NGINX_IMAGE
ARG HUGO_NGINX_VERSION
FROM ${HUGO_BUILDER_IMAGE}:${HUGO_BUILDER_VERSION} AS builder
ARG HUGO_BASE_URL
ARG HUGO_ENVIRONMENT
ARG HUGO_MINIFY
USER root
RUN install -d -o hugo -g hugo /src /public
USER hugo:hugo
WORKDIR /src
COPY --chown=hugo:hugo ./services/repository/ /src/
RUN set -eu; \
if [ -f package.json ]; then \
npm install --no-audit --no-fund --no-progress; \
fi
RUN set -eu; \
if [ "${HUGO_MINIFY}" = "true" ]; then \
hugo --minify -e "${HUGO_ENVIRONMENT}" -b "${HUGO_BASE_URL}" -d /public; \
else \
hugo -e "${HUGO_ENVIRONMENT}" -b "${HUGO_BASE_URL}" -d /public; \
fi
FROM ${HUGO_NGINX_IMAGE}:${HUGO_NGINX_VERSION}
COPY --from=builder /public/ /usr/share/nginx/html/
EXPOSE 80