Files
consentos/entrypoint.sh
Kunthawat Greethong 6e9726f28e
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
fix: bake SCANNER_SERVICE_URL into the combined image
Bake SCANNER_SERVICE_URL=http://127.0.0.1:8001 and PYTHONUNBUFFERED=1
into /etc/profile.d/consentos.sh inside the image and source that file
from /entrypoint.sh so every supervisord child (api, worker, beat,
scanner) inherits the same defaults — both for EasyPanel deploys and
local docker compose.

Drop the inline env injection in supervisord.conf since the entrypoint
now sets it. Single source of truth: the Dockerfile.
2026-06-15 22:32:43 +07:00

47 lines
1.2 KiB
Bash

#!/bin/sh
set -e
# Source runtime defaults baked into the image so supervisord's children
# (api, worker, beat, scanner) inherit them. Variables already set in the
# environment take precedence — easy panel / docker compose overrides win.
for f in /etc/profile.d/*.sh; do
[ -r "$f" ] && . "$f"
done
# Extract host and port from DATABASE_URL
DB_HOST=$(echo "$DATABASE_URL" | sed -E 's|.*@([^/:]+).*|\1|')
DB_PORT=$(echo "$DATABASE_URL" | sed -E 's|.*@[^/:]+:([0-9]+)/.*|\1|')
if [ -z "$DB_PORT" ] || [ "$DB_PORT" = "$DB_HOST" ]; then
DB_PORT="5432"
fi
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
) || (
(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"
exit 1
fi
echo " postgres not ready, retrying in 2s ... ($counter/$max_retries)"
sleep 2
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 "$@"