add react-nginx (#121)

add react-nginx

Signed-off-by: phamthainb <phamthai4643@gmail.com>
This commit is contained in:
Phạm Hồng Thái
2021-10-10 22:19:58 +07:00
committed by GitHub
parent 30d01c2cad
commit 263ba37b97
24 changed files with 36390 additions and 0 deletions

41
react-nginx/Dockerfile Executable file
View File

@@ -0,0 +1,41 @@
# 1. For build React app
FROM node:lts AS development
# Set working directory
WORKDIR /app
#
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json
# Same as npm install
RUN npm ci
COPY . /app
ENV CI=true
ENV PORT=3000
CMD [ "npm", "start" ]
FROM development AS build
RUN npm run build
# 2. For Nginx setup
FROM nginx:alpine
# Copy config nginx
COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html
# Remove default nginx static assets
RUN rm -rf ./*
# Copy static assets from builder stage
COPY --from=build /app/build .
# Containers run nginx with global directives and daemon off
ENTRYPOINT ["nginx", "-g", "daemon off;"]