|
|
- # Step 1: Use a base image with Node.js
- FROM node:16 AS build
-
- # Step 2: Set the working directory inside the container
- WORKDIR /app
-
- # Step 3: Copy package.json and package-lock.json (or yarn.lock)
- COPY package*.json ./
-
- # Step 4: Install dependencies
- RUN npm install
-
- # Step 5: Copy the rest of your application code
- COPY . .
-
- # Step 6: Build the React application
- RUN npm run build
-
- # Step 7: Use a base image to serve the application
- FROM nginx:alpine
-
- # Step 8: Copy the build output from the previous stage to the Nginx public directory
- COPY --from=build /app/build /usr/share/nginx/html
-
- # Step 9: Expose port 80 to the outside
- EXPOSE 80
-
- # Step 10: Start the Nginx server
- CMD ["nginx", "-g", "daemon off;"]
|