# Build stage FROM node:18-alpine AS builder WORKDIR /app # Copy package files COPY package*.json ./ # Install dependencies RUN npm ci # Copy source code COPY . . # Build the application with production environment ARG VITE_API_URL=/api ARG VITE_ENVIRONMENT=production RUN npm run build # Production stage FROM nginx:alpine # Install dumb-init for proper signal handling RUN apk add --no-cache dumb-init # Copy built files from builder COPY --from=builder /app/dist /usr/share/nginx/html # Copy nginx configuration COPY nginx.conf /etc/nginx/conf.d/default.conf # Create cache directory for nginx RUN mkdir -p /var/cache/nginx && \ chown -R nginx:nginx /var/cache/nginx # Expose port EXPOSE 80 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost/health || exit 1 # Use dumb-init to handle signals ENTRYPOINT ["dumb-init", "--"] # Start nginx CMD ["nginx", "-g", "daemon off;"]