# Stage 1: Build the application FROM node:22-alpine AS builder WORKDIR /app # Copy package files first to leverage Docker cache COPY package*.json ./ # Install dependencies RUN npm ci # Copy the rest of the application code COPY . . # Build the application ARG VITE_API_URL ENV VITE_API_URL=$VITE_API_URL RUN npm run build # Stage 2: Serve the application with Nginx FROM nginx:alpine AS production # Copy the built artifacts from the builder stage COPY --from=builder /app/dist /usr/share/nginx/html # Copy custom Nginx configuration COPY nginx.conf /etc/nginx/conf.d/default.conf # Expose port 80 EXPOSE 80 # Start Nginx CMD ["nginx", "-g", "daemon off;"]