# Stage 1: Build React App FROM node:16.13.2 WORKDIR /code # Copy package.json and package-lock.json COPY ./package.json /code/package.json COPY ./package-lock.json /code/package-lock.json COPY ./tailwind.config.js /code/tailwind.config.js COPY ./public /code/public COPY ./src /code/src # Install dependencies RUN npm install --legacy-peer-deps # # Set up a new user named "user" with user ID 1000 # RUN useradd -m -u 1001 user # # Switch to the "user" user # USER user # # Set home to the user's home directory # ENV HOME=/home/user \ # PATH=/home/user/.local/bin:$PATH # # Set the working directory to the user's home directory # WORKDIR $HOME/app # # Copy the current directory contents into the container at $HOME/app setting the owner to the user # COPY --chown=user . $HOME/app # Build the React app RUN npm run build # Start Nginx server CMD ["npm", "run", "start"]