Skip to content

Commit

Permalink
Merge pull request #622 from nscuro/issue-60
Browse files Browse the repository at this point in the history
Use `touch` instead of `mount` to check whether `config.json` is mounted
  • Loading branch information
nscuro authored Oct 23, 2023
2 parents 0ab41b6 + 8e5d144 commit 8aad056
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions docker/docker-entrypoint.d/30-oidc-configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@

set -e

# 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"
entrypoint_log() {
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
echo "$@"
fi
}

ME=$(basename $0)

if ! touch ./static/config.json 2>/dev/null; then
entrypoint_log "$ME: info: 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
| .API_WITH_CREDENTIALS = env.API_WITH_CREDENTIALS
CONFIG=$(jq '.API_BASE_URL = env.API_BASE_URL
| .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' \
./static/config.json > /tmp/config.json

# Override default config file
mv -f /tmp/config.json ./static/config.json
./static/config.json)
echo "${CONFIG}" > ./static/config.json
entrypoint_log "$ME: info: effective config: $(echo "${CONFIG}" | jq -c '.')"
fi

exec "$@"

0 comments on commit 8aad056

Please sign in to comment.