# Multi-Stage Production Dockerfile for CFI Frontend SPA # Stage 1: Build production bundle FROM node:22-alpine AS builder WORKDIR /app # Copy package manifests first for optimal layer caching COPY frontend/package.json frontend/package-lock.json ./ RUN npm ci --prefer-offline --no-audit # Copy source code and configuration files COPY frontend/ ./ # Build production distribution RUN npm run build # Stage 2: Minimalist, hardened Nginx runtime FROM nginx:1.27-alpine-slim AS runtime # Remove default Nginx welcome site RUN rm -rf /usr/share/nginx/html/* /etc/nginx/conf.d/default.conf # Copy custom SPA Nginx configuration COPY docker/nginx/frontend-nginx.conf /etc/nginx/conf.d/default.conf # Copy compiled assets from builder COPY --from=builder /app/dist /usr/share/nginx/html EXPOSE 80 HEALTHCHECK --interval=10s --timeout=3s --retries=3 \ CMD wget -qO- http://127.0.0.1/health || exit 1 CMD ["nginx", "-g", "daemon off;"]