fix: add alembic dir to image + run migrations in entrypoint
Some checks failed
CI / Detect changes (push) Has been cancelled
CI / API Lint (push) Has been cancelled
CI / API Tests (push) Has been cancelled
CI / Scanner Lint (push) Has been cancelled
CI / Scanner Tests (push) Has been cancelled
CI / Banner Lint & Typecheck (push) Has been cancelled
CI / Banner Tests (push) Has been cancelled
CI / Banner Build (push) Has been cancelled
CI / Admin UI Typecheck (push) Has been cancelled
CI / Admin UI Tests (push) Has been cancelled
CI / Admin UI Build (push) Has been cancelled

This commit is contained in:
Ami
2026-04-21 17:36:47 +07:00
parent 6b40c04b0d
commit 6211290923
2 changed files with 13 additions and 2 deletions

View File

@@ -2,7 +2,6 @@
set -e
# Extract host and port from DATABASE_URL
# Format: postgresql+asyncpg://user:pass@host:port/dbname
DB_HOST=$(echo "$DATABASE_URL" | sed -E 's|.*@([^/:]+).*|\1|')
DB_PORT=$(echo "$DATABASE_URL" | sed -E 's|.*@[^/:]+:([0-9]+)/.*|\1|')
@@ -14,7 +13,11 @@ echo "Waiting for postgres at $DB_HOST:$DB_PORT ..."
max_retries=30
counter=0
until pg_isready -h "$DB_HOST" -p "$DB_PORT" -q 2>/dev/null; do
until (
pg_isready -h "$DB_HOST" -p "$DB_PORT" -q 2>/dev/null
) || (
(echo > /dev/tcp/"$DB_HOST"/"$DB_PORT") 2>/dev/null
); do
counter=$((counter + 1))
if [ $counter -ge $max_retries ]; then
echo "ERROR: postgres at $DB_HOST:$DB_PORT not ready after ${max_retries}s"
@@ -26,4 +29,11 @@ done
echo "postgres is ready!"
# Run alembic migrations
if [ -f /app/alembic/env.py ]; then
echo "Running database migrations ..."
python -m alembic upgrade head
echo "Migrations complete!"
fi
exec "$@"