Skip to content

Commit

Permalink
chore(#2514): change dockerfile for productionization (#8)
Browse files Browse the repository at this point in the history
* chore: add workdir to dockerfile

* chore: changes to dockerfile

* chore: remove old setup

* chore: remove public path

* chore: add title
  • Loading branch information
kleyow authored Oct 12, 2021
1 parent 5654e79 commit 6ba9db2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
14 changes: 14 additions & 0 deletions .versionrc.js
Original file line number Diff line number Diff line change
@@ -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' }
]
}
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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=/
Expand Down
3 changes: 0 additions & 3 deletions docker/loadRuntimeConfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"

1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<html>
<head>
<title>Mojaloop Business Operations Portal</title>
<link href="https://fonts.googleapis.com/css?family=Fira+Sans:400,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Ubuntu:400,700" rel="stylesheet">
<script src="/runtime-env.js"></script>
Expand Down
8 changes: 5 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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`, `<script />`
// or `self.location`.
publicPath: 'auto',
},
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
Expand Down

0 comments on commit 6ba9db2

Please sign in to comment.