#!/bin/sh # Write the SPA's runtime operator config at container start. # # The nginx base image runs every /docker-entrypoint.d/*.sh before launching # nginx, so this overwrites the build-time public/config.js stub with the # operator's runtime config ($PUBLIC_API_BASE_URL, $PUBLIC_ENABLE_REGISTRATION). # That lets one prebuilt image target any backend origin and toggle sign-up # without rebuilding. Resolution + precedence live in src/config/env.ts. set -eu : "${PUBLIC_API_BASE_URL:=/api/v1}" : "${PUBLIC_ENABLE_REGISTRATION:=true}" ROOT="${NGINX_HTML_ROOT:-/usr/share/nginx/html}" # Anything but "false"/"0" enables the sign-up UI (mirrors parseFlag in env.ts). if [ "$PUBLIC_ENABLE_REGISTRATION" = "false" ] || [ "$PUBLIC_ENABLE_REGISTRATION" = "0" ]; then ENABLE_REGISTRATION=false else ENABLE_REGISTRATION=true fi printf 'window.__APP_CONFIG__={"apiBaseUrl":"%s","enableRegistration":%s};\n' \ "$PUBLIC_API_BASE_URL" "$ENABLE_REGISTRATION" \ >"$ROOT/config.js" echo "runtime-config: wrote apiBaseUrl=$PUBLIC_API_BASE_URL enableRegistration=$ENABLE_REGISTRATION to $ROOT/config.js"