# Stage 1: Build the React application FROM node:18-alpine AS build WORKDIR /app COPY package.json package-lock.json* ./ RUN npm install COPY . . RUN npm run build # Stage 2: Serve the application using Nginx FROM nginx:alpine # Remove default Nginx static assets RUN rm -rf /usr/share/nginx/html/* # Copy built app from the first stage COPY --from=build /app/dist /usr/share/nginx/html # Replace the default Nginx configuration COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]