-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22eed7a
commit 954fbab
Showing
1 changed file
with
25 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,38 @@ | ||
# Stage 1: Build React App | ||
FROM node:alpine as build | ||
# base image | ||
FROM node:14.17.0-alpine as build-stage | ||
|
||
WORKDIR /app | ||
# set working directory | ||
WORKDIR /case-flow-web/app | ||
|
||
COPY package.json package-lock.json ./ | ||
# add `/app/node_modules/.bin` to $PATH | ||
ENV PATH /case-flow-web/app/node_modules/.bin:$PATH | ||
|
||
RUN npm install | ||
RUN apk update && apk upgrade && \ | ||
apk add --no-cache bash git openssh | ||
|
||
COPY . . | ||
# install and cache app dependencies | ||
COPY package-lock.json /case-flow-web/app/package-lock.json | ||
COPY package.json /case-flow-web/app/package.json | ||
|
||
RUN npm run build | ||
RUN npm install --unsafe-perm --dev | ||
#RUN npm install [email protected] -g --silent | ||
|
||
COPY . /case-flow-web/app/ | ||
|
||
#RUN npm run build | ||
|
||
# Stage 2: Serve React App with NGINX | ||
FROM nginx:alpine | ||
FROM nginx:alpine as production-stage | ||
|
||
# Copy build files from the previous stage | ||
COPY --from=build /app/build /usr/share/nginx/html | ||
COPY --from=build-stage /case-flow-web/app/build /usr/share/nginx/html | ||
|
||
# Remove default nginx website | ||
RUN rm -rf /usr/share/nginx/html/* | ||
COPY ./nginx_conf/nginx.conf /etc/nginx/nginx.conf | ||
|
||
# Copy custom nginx configuration | ||
COPY nginx_conf/nginx.conf /etc/nginx/conf.d/default.conf | ||
# Fix permissions for Nginx directories | ||
RUN chgrp -R root /var/cache/nginx /var/run /var/log/nginx && \ | ||
chmod -R 770 /var/cache/nginx /var/run /var/log/nginx | ||
|
||
EXPOSE 80 | ||
# Allow Nginx to bind to port 80 | ||
USER root | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |