# Build stage FROM node:20-alpine AS builder WORKDIR /app # Accept build arg for API URL ARG VITE_API_URL=http://localhost:3000 ENV VITE_API_URL=$VITE_API_URL # Install pnpm RUN corepack enable && corepack prepare pnpm@latest --activate # Copy package files COPY package.json pnpm-lock.yaml* ./ # Install dependencies RUN pnpm install # Copy source code COPY . . # Build the application RUN pnpm build # Production stage with nginx FROM nginx:alpine AS runner # Copy custom nginx config COPY nginx.conf /etc/nginx/conf.d/default.conf # Copy built assets COPY --from=builder /app/dist /usr/share/nginx/html # Expose port EXPOSE 80 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD wget -q --spider http://localhost/ || exit 1 CMD ["nginx", "-g", "daemon off;"]