-
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
5ebb3d0
commit ae04a9e
Showing
2 changed files
with
26 additions
and
24 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
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,29 +1,31 @@ | ||
# base image | ||
FROM node:14.17.0-alpine as build-stage | ||
# "build-stage", based on Node.js, to build and compile the frontend | ||
# pull official base image | ||
FROM node:14-alpine as build-stage | ||
|
||
# add `/app/node_modules/.bin` to $PATH | ||
ENV PATH /node_modules/.bin:$PATH | ||
# set working directory | ||
WORKDIR /app | ||
|
||
RUN apk update && apk upgrade && \ | ||
apk add --no-cache bash git openssh | ||
# add `/app/node_modules/.bin` to $PATH | ||
ENV PATH /app/node_modules/.bin:$PATH | ||
|
||
# install and cache app dependencies | ||
COPY ./package*.json ./ | ||
RUN npm ci | ||
COPY . ./ | ||
# install app dependencies | ||
COPY package.json ./ | ||
COPY package-lock.json ./ | ||
|
||
RUN npm run build | ||
RUN npm install --silent | ||
RUN npm install react-scripts@3.4.1 -g --silent | ||
|
||
FROM artifacts.developer.gov.bc.ca/redhat-access-docker-remote/ubi8/nginx-122 AS deployer | ||
# create and set user permissions to app folder | ||
RUN mkdir -p node_modules/.cache && chmod -R 777 node_modules/.cache | ||
|
||
USER default | ||
|
||
# Copy the app built on build-stage to the resulting container. | ||
COPY --from=build-stage /opt/app-root/src/dist . | ||
# add app files | ||
COPY . ./ | ||
|
||
# Copy the default.conf to /etc/nginx/conf.d | ||
COPY --from=builder /opt/app-root/src/default.conf /etc/nginx/conf.d | ||
RUN npm run build | ||
|
||
COPY ./nginx.conf /etc/nginx/nginx.conf | ||
# Start nginx with the appropriate command | ||
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx | ||
FROM nginx:1.17 as production-stage | ||
RUN mkdir /app | ||
COPY --from=build-stage /app/build /usr/share/nginx/html | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
CMD ["nginx", "-g", "daemon off;"] |