npx create-react-app my-app
cd my-app
npm start
cd into the directory
cd my-app
touch Dockerfile
# Stage-1
FROM node:16-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY ./ ./
RUN npm run build
# Stage-2
FROM nginx:alpine
COPY --from=builder /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Build the docker image using the application code and Dockerfile
sudo docker build -t multi-stage .
Run the docker image
sudo docker run –d –p 8080:80 multi-stage