# Stage 1: Build the React application FROM node:18-alpine AS build WORKDIR /app # Copy package.json and package-lock.json COPY package*.json ./ # Install dependencies RUN npm install # Copy the rest of the application source code COPY . . # Build the application RUN npm run build # Stage 2: Serve the application with Nginx FROM nginx:1.21-alpine # Copy the built application from the build stage COPY --from=build /app/build /usr/share/nginx/html # Copy a custom Nginx configuration if needed (optional) COPY nginx.conf /etc/nginx/conf.d/default.conf # Expose port 80 EXPOSE 80 # Start Nginx CMD ["nginx", "-g", "daemon off;"]