# Stage 1: Build stage FROM node:20-alpine AS builder WORKDIR /app # Copy dependency definitions COPY package*.json ./ # Install dependencies RUN npm ci || npm install # Copy application source COPY . . # Build Vite application for production RUN npm run build # Stage 2: Production Nginx Server FROM nginx:alpine # Copy nginx configuration COPY nginx.conf /etc/nginx/conf.d/default.conf # Copy compiled static assets from build stage COPY --from=builder /app/dist /usr/share/nginx/html # Copy entrypoint script for dynamic runtime environment variables COPY docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh # Expose port 3000 EXPOSE 3000 # Set entrypoint and default command ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["nginx", "-g", "daemon off;"]