Dockerfile.slim
slim1 kB20 linesIn solution.zip
solution.zipDockerfile.slim
# Exercise 4: same as Dockerfile.multistage, but stage 2 uses nginx:stable-alpine-slim.
# Build: docker build -f Dockerfile.slim -t node-auth-app:slim .
# ---------- Stage 1: build the static files ----------
FROM 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-slim
# 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.