FROM alpine:3.22 ARG HUGO_VERSION=0.165.0 ARG TARGETARCH # the extended build is glibc-linked and will not run on alpine; nothing here # needs sass or webp, so the plain static build is the one to use RUN apk add --no-cache ca-certificates \ && case "${TARGETARCH}" in \ amd64) HUGO_ARCH=amd64 ;; \ arm64) HUGO_ARCH=arm64 ;; \ "") echo "TARGETARCH is empty; build with buildkit" >&2; exit 1 ;; \ *) echo "unsupported arch ${TARGETARCH}" >&2; exit 1 ;; \ esac \ && HUGO_TAR="hugo_${HUGO_VERSION}_linux-${HUGO_ARCH}.tar.gz" \ && BASE="https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}" \ && wget -qO "/tmp/${HUGO_TAR}" "${BASE}/${HUGO_TAR}" \ && wget -qO /tmp/checksums.txt "${BASE}/hugo_${HUGO_VERSION}_checksums.txt" \ && grep " ${HUGO_TAR}$" /tmp/checksums.txt > /tmp/expected.sha256 \ && test -s /tmp/expected.sha256 \ && (cd /tmp && sha256sum -c expected.sha256) \ && tar -xzf "/tmp/${HUGO_TAR}" -C /usr/local/bin hugo \ && rm -f "/tmp/${HUGO_TAR}" /tmp/checksums.txt /tmp/expected.sha256 WORKDIR /site COPY ./ /site EXPOSE 1313 CMD ["hugo", "server", "--bind", "0.0.0.0", "--port", "1313", "--baseURL", "http://127.0.0.1:1313/", "--appendPort=false"]