# Use the official Node.js image as a build stage FROM node:20-alpine AS build # Set the working directory WORKDIR /app # Copy package.json and package-lock.json COPY package*.json ./ # Install dependencies RUN npm install # Copy the rest of the application code COPY . . # Build the React application RUN npm run build # Use a lightweight web server to serve the build files FROM nginx:alpine # Copy the build files from the previous stage COPY --from=build /app/build /usr/share/nginx/html # Use custom nginx config so client-side routes (e.g. /contact, /about) fall back to index.html COPY nginx.conf /etc/nginx/conf.d/default.conf # Expose port 80 EXPOSE 80 # Start Nginx CMD ["nginx", "-g", "daemon off;"]