Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use touch instead of mount to check whether config.json is mounted #622

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "$@"