# Multi-stage build for frontend FROM node:20-alpine AS builder WORKDIR /app COPY frontend/package.json ./ # Install dependencies (ignore package-lock.json since it's outdated) RUN npm install COPY frontend/ ./ # Set build environment variables ENV VITE_OUTDIR=dist ENV VITE_ADDRESS_BASE_URL=/ # Build the project and verify output RUN npm run build:prod && ls -la && ls -la dist/ # Production stage with Nginx FROM nginx:alpine # Copy built assets COPY --from=builder /app/dist /usr/share/nginx/html # Selectable nginx configuration (default: nginx.conf). Use build-arg to switch. ARG NGINX_CONF=nginx.conf ENV NGINX_CONF=${NGINX_CONF} COPY ${NGINX_CONF} /etc/nginx/conf.d/default.conf # Create log directory RUN mkdir -p /var/log/nginx # Install curl for health check RUN apk add --no-cache curl # Expose port EXPOSE 80 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD curl -f http://localhost/ || exit 1 CMD ["nginx", "-g", "daemon off;"]