# Build Stage FROM node:22-alpine AS builder WORKDIR /app # Dependencies COPY package*.json ./ RUN npm ci # Source COPY . . # Build RUN npm run build # Production Stage FROM nginx:alpine # Copy built files COPY --from=builder /app/dist /usr/share/nginx/html # Nginx config for SPA routing RUN echo 'server { \ listen 80; \ root /usr/share/nginx/html; \ index index.html; \ \ location / { \ try_files $uri $uri/ $uri.html /index.html; \ } \ \ # Cache static assets \ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ { \ expires 1y; \ add_header Cache-Control "public, immutable"; \ } \ \ # Security headers \ add_header X-Frame-Options "SAMEORIGIN" always; \ add_header X-Content-Type-Options "nosniff" always; \ add_header X-XSS-Protection "1; mode=block" always; \ }' > /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]