/
/
/
1# Multi-stage build for React application
2FROM node:18-alpine AS build
3
4WORKDIR /app
5
6# Copy package files
7COPY package.json package-lock.json ./
8
9# Install dependencies
10RUN npm ci && npm cache clean --force
11
12# Copy source code
13COPY . .
14
15# Build the application
16RUN npm run build
17
18# Production stage with nginx
19FROM nginx:alpine
20
21# Copy nginx configuration
22COPY nginx.conf /etc/nginx/nginx.conf
23
24# Copy built application from build stage
25COPY --from=build /app/dist /usr/share/nginx/html
26
27# Expose port
28EXPOSE 80
29
30# Health check
31HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
32 CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1
33
34# Start nginx
35CMD ["nginx", "-g", "daemon off;"]
36