| # Stage 1: Build the React application | |
| FROM node:20-alpine as build | |
| WORKDIR /app | |
| # Install dependencies | |
| COPY package.json package-lock.json ./ | |
| RUN npm install | |
| # Build the application | |
| COPY . ./ | |
| RUN npm run build | |
| # Stage 2: Serve the application with Nginx | |
| FROM nginx:alpine | |
| # Copy built files from the build stage | |
| COPY --from=build /app/dist /usr/share/nginx/html | |
| # Copy custom Nginx configuration | |
| COPY nginx.conf /etc/nginx/conf.d/default.conf | |
| # Expose port 80 | |
| EXPOSE 80 | |
| CMD ["nginx", "-g", "daemon off;"] | |