# Build stage FROM node:20-alpine AS builder WORKDIR /app # Copy package files and install dependencies COPY package.json package-lock.json ./ RUN npm ci # Copy source code and build COPY . . RUN npm run build # Production stage (Nginx) FROM nginx:alpine # Copy built files to Nginx COPY --from=builder /app/dist /usr/share/nginx/html # Default Nginx config for Single Page Apps (Vite) RUN echo 'server { \ listen 80; \ location / { \ root /usr/share/nginx/html; \ index index.html; \ try_files $uri $uri/ /index.html; \ } \ }' > /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]