Files
supermarket/Dockerfile
T
davidandClaude Opus 5.5 233c6ac630 Phase 5 part 2: preview any branch of a site
Sites → Previews builds a branch with Hugo (drafts included) and serves it
under /preview/<site>/<branch>/, links rewritten to stay inside, behind a
sandboxing CSP so a branch's scripts can't act on the app or phone home.
The image now builds Hugo v0.170.1 from source; Alpine's 0.147.2 couldn't
build the site. Hugo's errors show their innermost cause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:02:23 -07:00

33 lines
1.4 KiB
Docker

# Supermarket's web app. Built locally by install.sh / update.sh through
# compose.yaml; nothing is pulled from a registry but the base images.
FROM golang:1.26-alpine AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG VERSION=dev
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X 'main.version=${VERSION}'" \
-o /out/supermarket ./cmd/supermarket
# Hugo, for the SEO and Sites modules, which build Hugo repositories to check
# a change and to preview a branch. Alpine's package lags years behind, and
# sites use newer template functions (hugo.Data needs 0.156+), so a pinned
# release is built from source; Go checks it against its checksum database.
# This is the standard edition: sites that need Sass (extended) won't build.
FROM golang:1.27-alpine AS hugo
ARG HUGO_VERSION=0.170.1
RUN CGO_ENABLED=0 go install -trimpath -ldflags "-s -w" github.com/gohugoio/hugo@v${HUGO_VERSION}
FROM alpine:3.22
# git: for the SEO and Sites modules, which change Hugo repositories.
RUN apk add --no-cache ca-certificates tzdata git
COPY --from=hugo /go/bin/hugo /usr/local/bin/hugo
COPY --from=build /out/supermarket /usr/local/bin/supermarket
LABEL org.opencontainers.image.title="supermarket"
ENV SUPERMARKET_DATA=/data
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
CMD wget -q -O /dev/null http://127.0.0.1:8080/healthz || exit 1
ENTRYPOINT ["/usr/local/bin/supermarket"]