Skip to content

Commit

Permalink
Improve test if static/config.json is writeable
Browse files Browse the repository at this point in the history
Fixes DependencyTrack#60

Signed-off-by: Steffen Mueller <[email protected]>
  • Loading branch information
muellerst-hg committed Jun 1, 2023
1 parent 70f003b commit 89c06eb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

set -e

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

# Check if config.json is mounted
if mount | grep '/static/config.json'; then
echo "config.json is mounted from host - ENV configuration will be ignored"
if ! touch $CONFIG_FILE 2>/dev/null; then
echo "can not modify config.json - ENV configuration will be ignored"
else
# Apply ENV vars to temporary config.json
jq '.API_BASE_URL = env.API_BASE_URL
Expand All @@ -14,10 +17,11 @@ else
| .OIDC_SCOPE = env.OIDC_SCOPE
| .OIDC_FLOW = env.OIDC_FLOW
| .OIDC_LOGIN_BUTTON_TEXT = env.OIDC_LOGIN_BUTTON_TEXT' \
./static/config.json > /tmp/config.json
$CONFIG_FILE > $TMP_FILE

# Override default config file
mv -f /tmp/config.json ./static/config.json
mv -f $TMP_FILE $CONFIG_FILE
fi

exec "$@"

0 comments on commit 89c06eb

Please sign in to comment.