40 lines
1.5 KiB
Bash
40 lines
1.5 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
mkdir -p /data
|
|
|
|
# SQLite won't create a missing parent directory for its database file.
|
|
for url in "$CACU_DATABASE_URL" "$CAMA_DATABASE_URL" "$TEA_DATABASE_URL" "$GOVERNANCE_DATABASE_URL"; do
|
|
case "$url" in
|
|
sqlite:///*) mkdir -p "$(dirname "${url#sqlite:///}")" ;;
|
|
esac
|
|
done
|
|
|
|
# The live indicator worker (webapi.indicadores_vivos) shares the image; the
|
|
# API container runs the migrations, so the worker starts after it.
|
|
if [ "$1" = "indicadores" ]; then
|
|
cd /app/WebApi
|
|
exec uv run --no-sync python -m webapi.indicadores_vivos
|
|
fi
|
|
|
|
# --no-sync: the image's environments were synced at build time; syncing at
|
|
# startup would try to reach the package index (and pull dev deps).
|
|
cd /app/Persistance
|
|
uv run --no-sync alembic -c persistance/cacu/alembic.ini upgrade head
|
|
uv run --no-sync alembic -c persistance/cama/alembic.ini upgrade head
|
|
uv run --no-sync alembic -c persistance/tea/alembic.ini upgrade head
|
|
uv run --no-sync alembic -c persistance/governance/alembic.ini upgrade head
|
|
|
|
cd /app/WebApi
|
|
# Container's own network namespace — no AirPlay conflict here, keep it on
|
|
# the port the Dockerfile EXPOSEs and docker-compose.yml maps from.
|
|
PORT="${PORT:-5000}"
|
|
# gunicorn, not Flask's development server. Long timeout: OCR over a
|
|
# multi-page scanned PDF runs inside a single request.
|
|
exec uv run --no-sync gunicorn \
|
|
--bind "0.0.0.0:${PORT}" \
|
|
--workers "${WEBAPI_WORKERS:-2}" \
|
|
--timeout "${WEBAPI_TIMEOUT:-600}" \
|
|
--access-logfile - \
|
|
"webapi:create_app()"
|