# Stage 1: Build the React application FROM node:20-alpine AS build WORKDIR /app # Copy package.json and package-lock.json to leverage Docker cache COPY package*.json ./ RUN npm install # Copy the rest of the application source code COPY . . RUN npm run build # Stage 2: Serve the application with Nginx FROM nginx:1.25-alpine AS production # Copy the built assets from the build stage COPY --from=build /app/dist /usr/share/nginx/html # Expose port 80 for the Nginx server EXPOSE 80 # Start Nginx when the container launches CMD ["nginx", "-g", "daemon off;"]