Files
CV_Site_Nuxt/Dockerfile
Noel c332c195a9
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Successful in 1m12s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Failing after 9s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
PR Check / AI code review (opencode) (pull_request) Failing after 15s
chore(deps): update node:26-slim docker digest to 18f03e4
2026-10-30 20:01:48 +00:00

64 lines
2.6 KiB
Docker

# Production image for the Nuxt CV site.
#
# Shape: a runnable Node server (SSR). `nuxt build` emits a self-contained
# Nitro server (.output/server/index.mjs plus its traced dependencies and
# .output/public), so the runtime stage needs no dependency installation.
# This answers the open question in OKF_Nuxt/open-questions.md; the gateway
# proxies to this server instead of embedding static files (see
# OKF_Nuxt/decisions/production-image.md).
#
# Layer order follows OKF_Nuxt/decisions/build-layer-order.md: manifests
# before source, so dependency changes invalidate everything but source-only
# edits invalidate almost nothing.
#
# Base image is digest-pinned to the same node:26-slim digest as the dev
# container (OKF_Nuxt/decisions/dev-container-shape.md) - verified for the
# runner's arm64 and this workstation's x86_64.
# syntax: no BuildKit-only features used, so the default frontend suffices.
FROM node:26-slim@sha256:18f03e4b532a63baf09809fe8349c2171807f1818cb6c5230fb12aecd5beda65 AS build
# pnpm pinned to the same version as CI (pr-checker.yml pins major 11) and
# the local toolchain (11.26.0). Installed via npm from the node image - no
# corepack, which current node images no longer bundle.
RUN npm install -g pnpm@11.26.0
WORKDIR /app
# Manifests first: their layer only invalidates when dependencies change.
# --ignore-scripts skips the `nuxt prepare` postinstall (the source is not
# copied yet); `nuxt build` prepares what it needs itself. Native binaries
# (esbuild, unrs-resolver) come from platform-specific optional packages,
# not install scripts, so skipping scripts is safe here.
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile --ignore-scripts
# Source last: the expensive layers above stay cached on source-only edits.
COPY . .
RUN pnpm build
FROM node:26-slim@sha256:18f03e4b532a63baf09809fe8349c2171807f1818cb6c5230fb12aecd5beda65
# pnpm is NOT installed in the runtime image: nothing here runs pnpm.
ENV NODE_ENV=production \
HOST=0.0.0.0 \
PORT=3000
WORKDIR /app
# Nitro's traced output includes .output/server/node_modules - the only
# thing the server needs. Runs as the image's non-root `node` user.
COPY --from=build --chown=node:node /app/.output ./.output
USER node
EXPOSE 3000
# node has no curl/wget in slim; use node's own fetch. The root path is
# served by the app itself, so a 2xx means the server is genuinely up.
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD node -e "fetch('http://127.0.0.1:3000/').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))"
CMD ["node", ".output/server/index.mjs"]