diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..67ccce4c6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules/ +.idea/ +dist/ diff --git a/docker/common/nginx/default.conf b/docker/common/nginx/default.conf new file mode 100644 index 000000000..7bbea1030 --- /dev/null +++ b/docker/common/nginx/default.conf @@ -0,0 +1,19 @@ +server { + listen 8080; + proxy_hide_header WWW-Authenticate; + root /usr/share/nginx/html; + location / { + index index.html; + expires -1; + proxy_hide_header WWW-Authenticate; + try_files $uri$args $uri$args/ $uri $uri/ /index.html =404; + } + gzip_min_length 1000; + gzip on; + gzip_http_version 1.0; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_buffers 16 8k; + gzip_types application/javascript text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; +} diff --git a/docker/red-ui-app/Dockerfile b/docker/red-ui-app/Dockerfile new file mode 100644 index 000000000..d7bc7181b --- /dev/null +++ b/docker/red-ui-app/Dockerfile @@ -0,0 +1,32 @@ +### STAGE 1: Build ### + +# We label our stage as ‘builder’ +FROM node:12.2-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 . . + +## Build the angular app in production mode and store the artifacts in dist folder +RUN yarn lint +RUN npm version patch --no-git-tag-version +RUN yarn build --prod --project=red-ui-app +### STAGE 2: Setup ### + +FROM nginx:1.17.6-alpine + +## Copy our default nginx config +COPY docker/common/nginx/default.conf /etc/nginx/conf.d/ + +## 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-app /usr/share/nginx/html +COPY docker/red-ui-app/docker-entrypoint.sh / +CMD ["/docker-entrypoint.sh"] diff --git a/docker/red-ui-app/docker-entrypoint.sh b/docker/red-ui-app/docker-entrypoint.sh new file mode 100755 index 000000000..c19cd47c4 --- /dev/null +++ b/docker/red-ui-app/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +CLIENT_ID="${CLIENT_ID:-false}" + +echo '{ + "CLIENT_ID":"'"$CLIENT_ID"' }' > /usr/share/nginx/html/config.json + +nginx -g 'daemon off;'