Fix Dokploy Bad Gateway: panel-first compose and stable boot

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
test2
2026-07-25 20:44:47 +03:00
co-authored by Cursor
parent 8320a7651e
commit d78797db82
5 changed files with 63 additions and 28 deletions
+18 -2
View File
@@ -1,6 +1,21 @@
#!/bin/sh
set -e
echo "==> VpnPanel starting"
# Always build DATABASE_URL from POSTGRES_* (Dokploy-friendly)
export DATABASE_URL="$(
python - <<'PY'
import os
from urllib.parse import quote_plus
user = os.environ.get("POSTGRES_USER", "vpn")
password = os.environ.get("POSTGRES_PASSWORD", "vpn")
db = os.environ.get("POSTGRES_DB", "vpn_panel")
print(f"postgresql+asyncpg://{quote_plus(user)}:{quote_plus(password)}@postgres:5432/{db}")
PY
)"
echo "Waiting for database..."
python - <<'PY'
import asyncio
@@ -11,7 +26,7 @@ from sqlalchemy import text
from sqlalchemy.ext.asyncio import create_async_engine
async def wait_db(retries: int = 40) -> None:
async def wait_db(retries: int = 60) -> None:
url = os.environ["DATABASE_URL"]
engine = create_async_engine(url)
for i in range(retries):
@@ -25,6 +40,7 @@ async def wait_db(retries: int = 40) -> None:
print(f"DB not ready ({i + 1}/{retries}): {exc}")
await asyncio.sleep(1)
await engine.dispose()
print("ERROR: database did not become ready", file=sys.stderr)
sys.exit(1)
@@ -37,5 +53,5 @@ alembic upgrade head
echo "Bootstrapping admin..."
python -m app.bootstrap
echo "Starting application..."
echo "Starting uvicorn..."
exec "$@"