Dockerfile.multistage

multistage1 kB23 linesIn solution.zip

solution.zipDockerfile.multistage

Dockerfile
# ---------- Stage 1: build the static files ----------
# $BUILDPLATFORM = the machine doing the build. The output is plain HTML/CSS/JS, the same
# for every CPU, so this stage runs natively once, even when building an arm64 image on
# an amd64 CI runner.
FROM --platform=$BUILDPLATFORM node:26-alpine AS builder

WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build            # outputs plain HTML/CSS/JS to /app/dist

# ---------- Stage 2: serve them with nginx ----------
FROM nginx:stable-alpine

# Our config: serve the files and forward /api/ to the backend.
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Only the built files are copied. Node, npm and node_modules stay behind.
COPY --from=builder /app/dist /usr/share/nginx/html

EXPOSE 80
# nginx's default command starts the server; no CMD needed.

In solution.zip