# Frontend Dockerfile - Multi-stage build FROM node:20-alpine AS builder # Set working directory WORKDIR /app # Copy package files COPY package*.json ./ # Install dependencies RUN npm ci # Copy application code COPY . . # Build the application # Support both VITE_API_BASE_URL and VITE_API_URL for compatibility # Defaults to /api (relative URL for nginx proxy in Docker) ARG VITE_API_BASE_URL=/api ARG VITE_API_URL ENV VITE_API_BASE_URL=$VITE_API_BASE_URL ENV VITE_API_URL=$VITE_API_URL # Copy .env file if it exists (for local development values) # This allows using existing .env file during build COPY .env* ./ # Build using Docker-specific script that skips TypeScript type checking # TypeScript errors should be fixed in development, but this allows Docker builds to proceed RUN npm run build:docker # Production stage FROM nginx:alpine # Copy built assets from 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 EXPOSE 80 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:80 || exit 1 # Start nginx CMD ["nginx", "-g", "daemon off;"]