48 lines
1.4 KiB
Docker
48 lines
1.4 KiB
Docker
### STAGE 1: Build ###
|
||
|
||
# We label our stage as ‘builder’
|
||
FROM node:14.17-alpine as builder
|
||
RUN apk add --update jq && rm -rf /var/cache/apk/*
|
||
COPY package.json yarn.lock ./
|
||
|
||
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
|
||
RUN yarn install && mkdir /ng-app && mv ./node_modules ./ng-app
|
||
|
||
WORKDIR /ng-app
|
||
|
||
COPY apps apps
|
||
COPY libs libs
|
||
COPY tools tools
|
||
COPY package.json package.json
|
||
COPY yarn.lock yarn.lock
|
||
COPY angular.json angular.json
|
||
COPY nx.json nx.json
|
||
COPY .eslintrc.json .eslintrc.json
|
||
COPY tsconfig.base.json tsconfig.base.json
|
||
COPY versions.sh version.sh
|
||
|
||
## Build the angular app in production mode and store the artifacts in dist folder
|
||
RUN yarn lint
|
||
RUN yarn build --configuration production --project=red-ui --base-href /ui/
|
||
### STAGE 2: Setup ###
|
||
|
||
|
||
FROM nginx:1.19.2-alpine
|
||
|
||
## Copy our default nginx config
|
||
COPY docker/common/nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||
|
||
## Remove default nginx website
|
||
RUN rm -rf /usr/share/nginx/html/*
|
||
|
||
## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder
|
||
COPY --from=builder /ng-app/dist/apps/red-ui /usr/share/nginx/html/ui
|
||
RUN chmod o+r -R /usr/share/nginx/html
|
||
RUN chmod g+r -R /usr/share/nginx/html
|
||
|
||
## Change permissions to enable openShift functionality
|
||
RUN chmod -R g+rwx /var/cache/nginx /var/run /var/log/nginx /usr/share /etc/nginx
|
||
|
||
COPY docker/red-ui/docker-entrypoint.sh /
|
||
CMD ["/docker-entrypoint.sh"]
|