Skip to content

Commit

Permalink
Introduce config.json template file
Browse files Browse the repository at this point in the history
Signed-off-by: Steffen Mueller <[email protected]>
  • Loading branch information
muellerst-hg committed Jun 13, 2023
1 parent 30d5b85 commit 73ebe9d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ reflect the base URL of a Dependency-Track server.
![Deployment Options](https://raw.githubusercontent.com/DependencyTrack/frontend/master/docs/images/Frontend-Deployment.svg?sanitize=true)

The front-end is deployed to a general purpose web server (e.g. NGINX or Apache). To configure the front-end
for this scenario, simply change the value of API_BASE_URL in static/config.json.
for this scenario, simply copy `static/config.tmpl.json` to `static/config.json` and change the value of API_BASE_URL in `static/config.json`.

```json
{
Expand Down
18 changes: 7 additions & 11 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@
set -e

CONFIG_FILE="./static/config.json"
TMP_FILE="/tmp/config.json"
TEMPLATE_FILE="./static/config.tmpl.json"

# Check if config.json is mounted
if ! touch $CONFIG_FILE 2>/dev/null; then
echo "can not modify config.json - ENV configuration will be ignored"
# Check if config.json exists
if test -f $CONFIG_FILE; then
echo "config.json already exists - ENV variables will be ignored"
else
# Apply ENV vars to temporary config.json
echo "Creating config.json using ENV variables"
jq '.API_BASE_URL = env.API_BASE_URL
| .API_WITH_CREDENTIALS = env.API_WITH_CREDENTIALS
| .API_WITH_CREDENTIALS = env.API_WITH_CREDENTIALS
| .OIDC_ISSUER = env.OIDC_ISSUER
| .OIDC_CLIENT_ID = env.OIDC_CLIENT_ID
| .OIDC_SCOPE = env.OIDC_SCOPE
| .OIDC_FLOW = env.OIDC_FLOW
| .OIDC_LOGIN_BUTTON_TEXT = env.OIDC_LOGIN_BUTTON_TEXT' \
$CONFIG_FILE > $TMP_FILE

# Override default config file
mv -f $TMP_FILE $CONFIG_FILE
$TEMPLATE_FILE > $CONFIG_FILE
fi

exec "$@"

File renamed without changes.

0 comments on commit 73ebe9d

Please sign in to comment.