- env.ts: supabase: SupabaseConnection | null resolved from env.js (supabaseUrl/supabaseAnonKey), VITE_SUPABASE_*, else null; half config refused - lib/supabase.ts: getSupabaseClient() null when unconfigured, one client per URL - entrypoint.sh writes the two public values; .env.example placeholders - Dockerfile copies packages/supabase manifest for the install layer - no UI change; 7 new tests (278 app)
45 lines
1.5 KiB
Bash
45 lines
1.5 KiB
Bash
#!/bin/sh
|
|
# Injects runtime env vars into /usr/share/nginx/html/env.js
|
|
# which is loaded by index.html before the React bundle.
|
|
# Values come from Docker env vars (set via env_file in docker-compose.yml).
|
|
|
|
set -e
|
|
|
|
ENV_JS="/usr/share/nginx/html/env.js"
|
|
|
|
# Escapes a value for safe embedding in a double-quoted JS string literal
|
|
# (backslashes, double quotes; newlines collapsed to spaces).
|
|
js_escape() {
|
|
printf '%s' "$1" | tr '\n' ' ' | sed 's/\\/\\\\/g; s/"/\\"/g'
|
|
}
|
|
|
|
SITE_NAME=$(js_escape "${APP_SITE_NAME:-Faunosteo}")
|
|
BRAND_NAME=$(js_escape "${APP_BRAND_NAME:-Faunosteo}")
|
|
FOOTER_NAME=$(js_escape "${APP_FOOTER_NAME:-Faunosteo}")
|
|
TAGLINE=$(js_escape "${APP_TAGLINE:-Outils pour ostéopathes animaliers}")
|
|
# Supabase public connection (anon key only; empty = backend disabled).
|
|
# The service-role key must never be set here.
|
|
SUPABASE_URL=$(js_escape "${APP_SUPABASE_URL:-}")
|
|
SUPABASE_ANON_KEY=$(js_escape "${APP_SUPABASE_ANON_KEY:-}")
|
|
|
|
cat > "$ENV_JS" <<EOF
|
|
window.__APP_CONFIG__ = {
|
|
siteName: "${SITE_NAME}",
|
|
brandName: "${BRAND_NAME}",
|
|
footerName: "${FOOTER_NAME}",
|
|
tagline: "${TAGLINE}",
|
|
supabaseUrl: "${SUPABASE_URL}",
|
|
supabaseAnonKey: "${SUPABASE_ANON_KEY}"
|
|
};
|
|
EOF
|
|
|
|
echo "env.js written: APP_BRAND_NAME=${APP_BRAND_NAME:-Faunosteo}"
|
|
|
|
# Replace PORT placeholder in nginx config if needed
|
|
# (nginx:alpine supports envsubst via templates; we keep it explicit)
|
|
export PORT="${PORT:-8080}"
|
|
envsubst '${PORT}' < /etc/nginx/conf.d/default.conf > /tmp/nginx_default.conf
|
|
cp /tmp/nginx_default.conf /etc/nginx/conf.d/default.conf
|
|
|
|
exec nginx -g "daemon off;"
|