Files
astro-website/Dockerfile
Santhosh Janardhanan 26a8c97841
Some checks failed
ci / site (push) Has been cancelled
publish-image / publish (push) Has been cancelled
issue with notch
2026-02-10 20:57:28 -05:00

47 lines
1.5 KiB
Docker

FROM node:24-alpine AS builder
WORKDIR /app/site
ARG PUBLIC_ENABLE_SW=true
ENV PUBLIC_ENABLE_SW=$PUBLIC_ENABLE_SW
ARG PUBLIC_ASSET_VERSION
ENV PUBLIC_ASSET_VERSION=$PUBLIC_ASSET_VERSION
# Public, build-time config (baked into static HTML via Astro/Vite).
ARG PUBLIC_SITE_URL
ARG PUBLIC_UMAMI_SCRIPT_URL
ARG PUBLIC_UMAMI_WEBSITE_ID
ENV PUBLIC_SITE_URL=$PUBLIC_SITE_URL
ENV PUBLIC_UMAMI_SCRIPT_URL=$PUBLIC_UMAMI_SCRIPT_URL
ENV PUBLIC_UMAMI_WEBSITE_ID=$PUBLIC_UMAMI_WEBSITE_ID
COPY site/package.json site/package-lock.json ./
RUN npm ci --no-audit --no-fund
COPY site/ ./
# Content is fetched before build (typically in CI) and committed into the build context at
# `site/content/cache/content.json`. If env vars aren't configured, the fetch step gracefully
# skips sources and/or uses last-known-good cache.
RUN npm run build
FROM nginx:1.27-alpine
ARG BUILD_SHA=unknown
ARG BUILD_DATE=unknown
ARG BUILD_REF=unknown
LABEL org.opencontainers.image.title="fast-website"
LABEL org.opencontainers.image.description="Lightweight, SEO-first static site packaged as an nginx image."
LABEL org.opencontainers.image.revision=$BUILD_SHA
LABEL org.opencontainers.image.created=$BUILD_DATE
LABEL org.opencontainers.image.source=$BUILD_REF
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/site/dist/ /usr/share/nginx/html/
# Operator-friendly version visibility.
RUN printf '{\n "sha": "%s",\n "builtAt": "%s",\n "ref": "%s"\n}\n' "$BUILD_SHA" "$BUILD_DATE" "$BUILD_REF" \
> /usr/share/nginx/html/build.json
EXPOSE 80