# Multi-stage build for Angular frontend FROM node:18-alpine as frontend-builder # Install dependencies for native modules RUN apk add --no-cache python3 make g++ WORKDIR /frontend # Copy package files first for better layer caching COPY frontend/package*.json ./ # Clean install dependencies with explicit platform targeting # This ensures esbuild and other native modules are built for Alpine Linux RUN npm ci --force # Copy frontend source (excluding node_modules via .dockerignore) COPY frontend/src ./src COPY frontend/public ./public COPY frontend/angular.json ./ COPY frontend/tsconfig*.json ./ # Build the Angular app for production RUN npm run build --verbose # Production image with nginx FROM nginx:alpine # Copy built Angular app from the browser subdirectory COPY --from=frontend-builder /frontend/dist/frontend/browser /usr/share/nginx/html # Copy nginx configuration COPY nginx.conf /etc/nginx/nginx.conf # Expose port 80 EXPOSE 80 # Start nginx CMD ["nginx", "-g", "daemon off;"]