Skip to content

Commit

Permalink
prod image config creation
Browse files Browse the repository at this point in the history
  • Loading branch information
v-rocheleau committed Mar 13, 2024
1 parent d7a957f commit 8387e7a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ WORKDIR /bento-public

COPY entrypoint.bash .
COPY package.json .
COPY create_config_prod.js .

# Copy web app
COPY --from=nodebuilder /node/build/www /bento-public/www
Expand All @@ -46,4 +47,4 @@ COPY --from=nodebuilder /node/build/www /bento-public/www
COPY --from=gobuilder /build/reactapp /bento-public/reactapp

ENTRYPOINT [ "/bin/bash", "./entrypoint.bash" ]
CMD [ "./reactapp" ]
CMD ["bash", "./run.bash"]
22 changes: 22 additions & 0 deletions create_config_prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const parseBoolean = (value) => ["true", "1", "yes"].includes((value || "").toLocaleLowerCase());

const siteConfig = {
CLIENT_NAME: process.env.CLIENT_NAME || null,
PORTAL_URL: process.env.BENTO_PUBLIC_PORTAL_URL || null,
TRANSLATED: parseBoolean(process.env.BENTO_PUBLIC_TRANSLATED),
BEACON_URL: process.env.BEACON_URL || null,
BEACON_UI_ENABLED: parseBoolean(process.env.BENTO_BEACON_UI_ENABLED),

// Authentication
BENTO_PUBLIC_URL: process.env.BENTO_PUBLIC_URL || null,
CLIENT_ID: process.env.CLIENT_ID || null,
OPENID_CONFIG_URL: process.env.OPENID_CONFIG_URL || null,
};

if (typeof require !== "undefined" && require.main === module) {
process.stdout.write(`BENTO_PUBLIC_CONFIG = ${JSON.stringify(siteConfig, null, 2)};\n`);
}

module.exports = {
siteConfig,
};
10 changes: 10 additions & 0 deletions run.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

CONFIG_FILE="www/public/config.js"

echo "[bento_public] [entrypoint] writing ${CONFIG_FILE}"
node ./create_config_prod.js # Echo out to logs
node ./create_config_prod.js > "${CONFIG_FILE}"

echo "[bento_public] [entrypoint] starting web server"
./reactapp

0 comments on commit 8387e7a

Please sign in to comment.