auto-form / entrypoint.sh
Menixis's picture
Claude Opus 4.8 (1M context)
Add Microsoft Entra ID login + ember dark theme
e6660cd
Raw History Blame Contribute Delete
1.37 kB
#!/usr/bin/env bash
# =============================================================================
# Container entrypoint (Hugging Face Spaces / Docker).
#
# Streamlit native auth reads its [auth] config from .streamlit/secrets.toml,
# which is gitignored (it holds the client secret). On HF there's no such file,
# so we materialise it here from Space secrets (injected as env vars) before
# launching Streamlit. Local dev doesn't use this script — it runs
# `streamlit run` directly against the local .streamlit/secrets.toml.
#
# Required HF Space secrets/variables:
# AUTH_CLIENT_ID, AUTH_CLIENT_SECRET, AUTH_COOKIE_SECRET,
# AUTH_REDIRECT_URI, AUTH_SERVER_METADATA_URL
# =============================================================================
set -e
if [ -n "$AUTH_CLIENT_ID" ]; then
mkdir -p .streamlit
cat > .streamlit/secrets.toml <<EOF
[auth]
redirect_uri = "${AUTH_REDIRECT_URI}"
cookie_secret = "${AUTH_COOKIE_SECRET}"
client_id = "${AUTH_CLIENT_ID}"
client_secret = "${AUTH_CLIENT_SECRET}"
server_metadata_url = "${AUTH_SERVER_METADATA_URL}"
EOF
echo "[entrypoint] wrote .streamlit/secrets.toml from Space secrets"
else
echo "[entrypoint] WARNING: AUTH_CLIENT_ID not set — sign-in will not work until the Space secrets are configured"
fi
exec streamlit run streamlit_app.py --server.port "${PORT:-7860}" --server.address 0.0.0.0