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
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:
@@ -47,6 +47,7 @@ COPY --from=builder /install /usr/local
|
|||||||
|
|
||||||
# Copy application code
|
# Copy application code
|
||||||
COPY apps/api/src ./src
|
COPY apps/api/src ./src
|
||||||
|
COPY apps/api/alembic ./alembic
|
||||||
COPY apps/scanner/src ./src_scanner
|
COPY apps/scanner/src ./src_scanner
|
||||||
|
|
||||||
RUN if [ -d src_scanner ]; then \
|
RUN if [ -d src_scanner ]; then \
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Extract host and port from DATABASE_URL
|
# 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_HOST=$(echo "$DATABASE_URL" | sed -E 's|.*@([^/:]+).*|\1|')
|
||||||
DB_PORT=$(echo "$DATABASE_URL" | sed -E 's|.*@[^/:]+:([0-9]+)/.*|\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
|
max_retries=30
|
||||||
counter=0
|
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))
|
counter=$((counter + 1))
|
||||||
if [ $counter -ge $max_retries ]; then
|
if [ $counter -ge $max_retries ]; then
|
||||||
echo "ERROR: postgres at $DB_HOST:$DB_PORT not ready after ${max_retries}s"
|
echo "ERROR: postgres at $DB_HOST:$DB_PORT not ready after ${max_retries}s"
|
||||||
@@ -26,4 +29,11 @@ done
|
|||||||
|
|
||||||
echo "postgres is ready!"
|
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 "$@"
|
exec "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user