Initial commit

This commit is contained in:
nholtware 2026-11-05 02:28:09 -06:00
commit 3a8e7184d5
32 changed files with 5218 additions and 0 deletions

View file

@ -0,0 +1,26 @@
#!/bin/sh
# Run by the nginx image's entrypoint before nginx starts. Writes the runtime
# config the SPA reads as window.__APP_CONFIG__, so one image serves every
# environment. To expose a new env var to the browser, add its name to VARS.
# Never put secrets here: everything in config.js is public.
set -eu
VARS="API_BASE_URL APP_NAME"
OUT=/usr/share/nginx/html/config.js
: "${API_BASE_URL:=/api}"
: "${APP_NAME:=app}"
json_escape() {
printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g'
}
body=""
for name in $VARS; do
eval "value=\${$name:-}"
[ -n "$body" ] && body="$body,"
body="$body\"$name\":\"$(json_escape "$value")\""
done
printf 'window.__APP_CONFIG__ = {%s};\n' "$body" > "$OUT"
echo "10-config.sh: wrote $OUT"