React js + Dockerfile + Nginx production
Feb 14, 2022
# build environment
FROM node:alpine as builder
RUN npm install nodemon -g — save
WORKDIR /app
COPY . .
RUN npm cache clean — force
RUN npm i
# dev
# EXPOSE 3000 < Is defualt post not setup
CMD [ “npm”, “run”, “start” ]
#production
# RUN npm run build
# # nginx state for serving content
# FROM nginx:1.19.0
# # Set working directory to nginx asset directory
# WORKDIR /usr/share/nginx/html
# # Remove default nginx static assets
# RUN rm -rf ./*
# # Copy static assets from builder stage
# COPY — from=builder /app/build .
# # Containers run nginx with global directives and daemon off
# ENTRYPOINT [“nginx”, “-g”, “daemon off;”]