# ---- Build stage ---- FROM node:20-alpine AS builder WORKDIR /app # install deps first (better caching) COPY package.json package-lock.json ./ RUN npm ci # copy source and build COPY . . RUN npm run build # ---- Production stage ---- FROM nginx:alpine # remove default nginx static files RUN rm -rf /usr/share/nginx/html/* # copy built app COPY --from=builder /app/dist /usr/share/nginx/html # optional: custom nginx config (for SPA routing) # COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]