Skip to main content

Docker Build Strategy

All applications use multi-stage Dockerfiles to produce minimal production images.

Multi-Stage Pattern

# Stage 1: Build
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Stage 2: Production
FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80

Why Multi-Stage?

  • Smaller images: The final image contains only the built artifacts and Nginx — no node_modules, no source code, no build tools
  • Security: Fewer packages in the final image means a smaller attack surface
  • Caching: Docker layer caching makes rebuilds fast when only source code changes

Client vs Server Images

TypeBase ImageContents
Clientnginx:alpineStatic build output (HTML/CSS/JS)
Servernode:22-alpineNode.js runtime + compiled server code

Build Flow