## Writing Multi-Stage Dockerfiles Multi-stage Docker builds separate the build environment from the final runtime image, shrinking image sizes from 1GB down to under 100MB. ```dockerfile # Multi-stage Next.js Dockerfile FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM node:20-alpine AS runner WORKDIR /app COPY --from=builder /app/public ./public COPY --from=builder /app/.next/standalone ./ EXPOSE 3000 CMD ["node", "server.js"] ```