red-ui/docker/red-ui/Dockerfile
2023-06-19 15:56:37 +03:00

72 lines
2.1 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

FROM node:18.12-buster as prep
RUN ls -al
RUN cat .dockerenv
RUN printenv
RUN apt-get update && apt-get install -y jq
COPY package.json /tmp
RUN jq '{ dependencies, devDependencies, peerDependencies, scripts: (.scripts | { postinstall }) }' < /tmp/package.json > /tmp/deps.json
# keep postinstall script
### STAGE 1: Build ###
# We label our stage as builder
FROM node:18.12-buster as builder
COPY --from=prep /tmp/deps.json ./package.json
COPY 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
ARG bamboo_sonarqube_api_token_secret
ENV bamboo_sonarqube_api_token_secret=$bamboo_sonarqube_api_token_secret
WORKDIR /ng-app
COPY apps apps
COPY libs libs
COPY tools tools
COPY package.json package.json
#RUN jq --arg version "$(jq .FRONTEND_APP_VERSION version.json -r | cat)" '.version = $version' package.json
#RUN cat package.json
COPY yarn.lock yarn.lock
COPY nx.json nx.json
COPY .eslintrc.json .eslintrc.json
COPY tsconfig.json tsconfig.json
COPY paligo-styles paligo-styles
COPY sonar.js sonar.js
## Build the angular app in production mode and store the artifacts in dist folder
# Fix auth issue then uncomment
# RUN node sonar.js
RUN yarn run build-lint-all
RUN yarn run build-paligo-styles
CMD ["/bin/cp", "-r", "/ng-app/dist/paligo-styles", "/tmp/styles-export"]
### STAGE 2: Setup ###
FROM nginx:1.21.4-alpine
RUN apk add --update nano && rm -rf /var/cache/apk/*
## 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"]