mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 02:41:23 +02:00
Replace window injection and build-time env vars with runtime config loaded from /config.json (generated by Docker entrypoint). This fixes the staging deployment issue where apps were requesting localhost URLs instead of production URLs. Changes: - Add runtime.ts config loader with Zod validation (fail-hard in prod) - Disable SSR via +layout.ts (apps are client-only SPAs) - Update API clients and auth stores to use async config getters - Add docker-entrypoint.sh scripts to generate config.json at startup - Update Dockerfiles with ENTRYPOINT for config generation - Simplify docker-compose.staging.yml env vars (12-factor pattern) - Add static/config.json as dev fallback (localhost defaults) - Fix onMount return type (Svelte 5 compatibility) - Add zod dependency to Picture app - Add backward compat exports for Contacts app Apps updated: - Clock (port 3017) - Chat (port 3002) - Picture (port 3006) - Contacts (port 3015) - Calendar (port 3016) - Manacore (multi-app platform) Benefits: - Build once, deploy anywhere (same Docker image for all envs) - Configuration in environment, not code (12-factor compliance) - Fail-hard on missing/invalid config in production - No accidental SSR localhost fallbacks - Schema validation ensures all required URLs are present
26 lines
697 B
Bash
26 lines
697 B
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
echo "🔧 Generating runtime configuration..."
|
|
|
|
# Environment variables with development defaults
|
|
BACKEND_URL=${BACKEND_URL:-"http://localhost:3015"}
|
|
AUTH_URL=${AUTH_URL:-"http://localhost:3001"}
|
|
|
|
echo "📝 Config values:"
|
|
echo " BACKEND_URL: $BACKEND_URL"
|
|
echo " AUTH_URL: $AUTH_URL"
|
|
|
|
# Generate config.json from environment variables
|
|
cat > /app/apps/contacts/apps/web/build/client/config.json <<EOF
|
|
{
|
|
"BACKEND_URL": "${BACKEND_URL}",
|
|
"AUTH_URL": "${AUTH_URL}"
|
|
}
|
|
EOF
|
|
|
|
echo "✅ Configuration generated at /app/apps/contacts/apps/web/build/client/config.json"
|
|
cat /app/apps/contacts/apps/web/build/client/config.json
|
|
|
|
echo "🚀 Starting Contacts web app..."
|
|
exec "$@"
|