From 6ba9db25fd897498e181f14a16fe09aa08c49852 Mon Sep 17 00:00:00 2001 From: Kevin Leyow Date: Tue, 12 Oct 2021 10:10:55 -0500 Subject: [PATCH] chore(#2514): change dockerfile for productionization (#8) * chore: add workdir to dockerfile * chore: changes to dockerfile * chore: remove old setup * chore: remove public path * chore: add title --- .versionrc.js | 14 ++++++++++++++ Dockerfile | 6 +----- docker-compose.yaml | 1 - docker/loadRuntimeConfig.sh | 3 --- public/index.html | 1 + webpack.config.js | 8 +++++--- 6 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 .versionrc.js diff --git a/.versionrc.js b/.versionrc.js new file mode 100644 index 0000000..10663dd --- /dev/null +++ b/.versionrc.js @@ -0,0 +1,14 @@ +module.exports = { + header: '# Changelog: [mojaloop/reporting-hub-bop-shell](https://github.com/mojaloop/reporting-hub-bop-shell)', + types: [ + { type: 'feat', section: 'Features' }, + { type: 'fix', section: 'Bug Fixes' }, + { type: 'chore', section: 'Maintenance' }, + { type: 'ci', section: 'CI/CD' }, + { type: 'docs', section: 'Documentation' }, + { type: 'style', section: 'Style Improvements' }, + { type: 'refactor', section: 'Code Refactor' }, + { type: 'perf', section: 'Performance' }, + { type: 'test', section: 'Tests' } + ] +} diff --git a/Dockerfile b/Dockerfile index 24bfad1..743a069 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ FROM node:lts-alpine as builder - WORKDIR /opt/reporting-hub-bop-shell ENV PATH /opt/reporting-hub-bop-shell/node_modules/.bin:$PATH @@ -21,14 +20,11 @@ ENV REACT_APP_VERSION=$REACT_APP_VERSION ARG REACT_APP_COMMIT ENV REACT_APP_COMMIT=$REACT_APP_COMMIT -# Public Path - Placeholder that is overwritten at runtime -ARG PUBLIC_PATH -ENV PUBLIC_PATH=__PUBLIC_PATH__ - RUN yarn build # Second part, create a config at boostrap via entrypoint and and serve it FROM nginx:1.16.0-alpine +WORKDIR /usr/share/nginx/html # JQ is used to convert from JSON string to json file in bash RUN apk add --no-cache jq diff --git a/docker-compose.yaml b/docker-compose.yaml index edbbf94..a0f5ecd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,7 +13,6 @@ services: cache_from: - mojaloop/reporting-hub-bop-shell environment: - - PUBLIC_PATH=http://localhost:8080/ - AUTH_API_BASE_URL=/ - AUTH_MOCK_API=true - REMOTE_API_BASE_URL=/ diff --git a/docker/loadRuntimeConfig.sh b/docker/loadRuntimeConfig.sh index 2b02f3b..ca6a9a4 100644 --- a/docker/loadRuntimeConfig.sh +++ b/docker/loadRuntimeConfig.sh @@ -5,8 +5,5 @@ sed -i 's#__REMOTE_1_URL__#'"$REMOTE_1_URL"'#g' /usr/share/nginx/html/index.html sed -i 's#__REMOTE_2_URL__#'"$REMOTE_2_URL"'#g' /usr/share/nginx/html/runtime-env.js sed -i 's#__REMOTE_2_URL__#'"$REMOTE_2_URL"'#g' /usr/share/nginx/html/index.html -sed -i 's#__PUBLIC_PATH__#'"$PUBLIC_PATH"'#g' /usr/share/nginx/html/index.html -sed -i 's#__PUBLIC_PATH__#'"$PUBLIC_PATH"'#g' /usr/share/nginx/html/main.js - exec "$@" diff --git a/public/index.html b/public/index.html index 6f862c2..eb9af01 100644 --- a/public/index.html +++ b/public/index.html @@ -1,5 +1,6 @@ + Mojaloop Business Operations Portal diff --git a/webpack.config.js b/webpack.config.js index f0ddeee..04b4f38 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -10,11 +10,10 @@ require('dotenv').config({ path: './.env', }); -const { DEV_PORT, VERCEL_URL, PUBLIC_PATH } = process.env; +const { DEV_PORT } = process.env; const config = { DEV_PORT, - PUBLIC_PATH: VERCEL_URL ? `https://${VERCEL_URL}/` : PUBLIC_PATH, }; module.exports = { @@ -59,7 +58,10 @@ module.exports = { }, output: { path: path.resolve(__dirname, 'dist'), - publicPath: config.PUBLIC_PATH, // Where it's going to be expected to be published for being externally loaded + // It automatically determines the public path from either + // `import.meta.url`, `document.currentScript`, `