# Stage 1: Build the React app FROM node:16-alpine AS build # Set 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 app RUN npm run build # Stage 2: Serve the built app with a lightweight web server FROM nginx:alpine # Set up a new user named "user" with user ID 1001 RUN adduser -D -u 1001 user # Switch to the root user to perform privileged operations USER root # Remove the default Nginx configuration file RUN rm /etc/nginx/conf.d/default.conf # Copy the built files from the previous stage COPY --from=build /app/dist /usr/share/nginx/html # Replace the default nginx.conf with our configuration COPY nginx.conf /etc/nginx/conf.d # Change ownership of the