#!/bin/sh set -eu python - <<'PY' import os import time from sqlalchemy import create_engine, text if os.getenv("MIGRATION_CONTEXT") == "1": engine = create_engine(os.environ["DATABASE_URL"], connect_args={ "connect_timeout": 3, "sslmode": "verify-full", "sslrootcert": os.getenv("DB_CA_FILE", "/run/tls/service-ca.crt"), }) else: # Uses this service's scoped AppRole KV path and verifies the DB TLS identity. from src.database import engine for attempt in range(60): try: with engine.connect() as connection: connection.execute(text("SELECT 1")) break except Exception: if attempt == 59: raise time.sleep(1) PY exec "$@"