Files
ThothII/docker/frontend-entrypoint.sh

19 lines
543 B
Bash

#!/bin/sh
set -eu
backend_base_url=${BACKEND_BASE_URL-/api}
if ! /usr/local/bin/validate-backend-url "$backend_base_url"; then
echo "Invalid BACKEND_BASE_URL: use empty/root, /api, or a valid http(s) base without credentials, query, or fragment" >&2
exit 2
fi
runtime_config=$(jq -cn --arg backend_base_url "$backend_base_url" \
'{backendBaseUrl: $backend_base_url}')
printf 'window.__THOTHII_CONFIG__ = %s;\n' "$runtime_config" \
> /usr/share/nginx/html/config.js
if [ "$#" -gt 0 ]; then
exec "$@"
fi
exec nginx -g 'daemon off;'