diff --git a/Dockerfile b/Dockerfile index 8abb8a7..ddab31f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,18 @@ FROM node:lts-alpine as builder - -WORKDIR /opt/reporting-hub-bop-shell -ENV PATH /opt/reporting-hub-bop-shell/node_modules/.bin:$PATH +WORKDIR /opt/reporting-hub-bop-role-ui +ENV PATH /opt/reporting-hub-bop-role-ui/node_modules/.bin:$PATH RUN apk add --no-cache -t build-dependencies git make gcc g++ python libtool autoconf automake \ && cd $(npm root -g)/npm \ && npm config set unsafe-perm true \ && npm install -g node-gyp -COPY package.json /opt/reporting-hub-bop-shell/ -COPY yarn.lock /opt/reporting-hub-bop-shell/ +COPY package.json /opt/reporting-hub-bop-role-ui/ +COPY yarn.lock /opt/reporting-hub-bop-role-ui/ RUN yarn --frozen-lockfile -COPY ./ /opt/reporting-hub-bop-shell/ +COPY ./ /opt/reporting-hub-bop-role-ui/ # Adds the package version and commit hash ARG REACT_APP_NAME @@ -25,19 +24,13 @@ 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 - -COPY --from=builder /opt/reporting-hub-bop-shell/dist/ /usr/share/nginx/html +COPY --from=builder /opt/reporting-hub-bop-role-ui/dist/ /usr/share/nginx/html RUN rm /etc/nginx/conf.d/default.conf /etc/nginx/nginx.conf COPY nginx/nginx.conf /etc/nginx/nginx.conf COPY nginx/start.sh /usr/share/nginx/start.sh diff --git a/docker-compose.yaml b/docker-compose.yaml index 42a6c19..86cc3cd 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,7 +13,6 @@ services: cache_from: - mojaloop/reporting-hub-bop-role-ui environment: - - PUBLIC_PATH=http://localhost:8081/ - REACT_APP_API_BASE_URL=http://localhost:3008/ - REACT_APP_MOCK_API=false ports: diff --git a/docker/loadRuntimeConfig.sh b/docker/loadRuntimeConfig.sh index ecbaa51..f314137 100644 --- a/docker/loadRuntimeConfig.sh +++ b/docker/loadRuntimeConfig.sh @@ -2,8 +2,4 @@ sed -i 's#__REACT_APP_API_BASE_URL__#'"$REACT_APP_API_BASE_URL"'#g' /usr/share/nginx/html/runtime-env.js sed -i 's#__REACT_APP_MOCK_API__#'"$REACT_APP_MOCK_API"'#g' /usr/share/nginx/html/runtime-env.js -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 -sed -i 's#__PUBLIC_PATH__#'"$PUBLIC_PATH"'#g' /usr/share/nginx/html/app.js - exec "$@" diff --git a/webpack.config.js b/webpack.config.js index 3096f03..ec7f725 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -10,12 +10,10 @@ require('dotenv').config({ path: './.env', }); -const { DEV_PORT, VERCEL_URL, PUBLIC_PATH, ROLE_API_URL } = process.env; +const { DEV_PORT } = process.env; const config = { DEV_PORT, - PUBLIC_PATH: VERCEL_URL ? `https://${VERCEL_URL}/` : PUBLIC_PATH, - ROLE_API_URL, }; const { ModuleFederationPlugin } = webpack.container; @@ -52,7 +50,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`, `