diff --git a/.github/workflows/caseflow_web_os.yml b/.github/workflows/caseflow_web_os.yml index d0c5abe0a..b853dcc27 100644 --- a/.github/workflows/caseflow_web_os.yml +++ b/.github/workflows/caseflow_web_os.yml @@ -43,10 +43,10 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' cache-dependency-path: "./app/caseflow_web/package-lock.json" - - run: npm install --force - working-directory: ./app/caseflow_web - - run: CI=false npm run build - working-directory: ./app/caseflow_web + # - run: npm install --force + # working-directory: ./app/caseflow_web + # - run: CI=false npm run build + # working-directory: ./app/caseflow_web - name: Set ENV variables diff --git a/app/caseflow_web/Dockerfile b/app/caseflow_web/Dockerfile index 3c593ff49..5c4405d13 100644 --- a/app/caseflow_web/Dockerfile +++ b/app/caseflow_web/Dockerfile @@ -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;"] \ No newline at end of file