#!/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 cd /app/WebApi # --no-sync: the environment was synced at build time; syncing at startup # would try to reach the package index (and pull dev deps). for domain in cacu cama tea governance; do uv run --no-sync alembic -c "/app/Persistance/persistance/$domain/alembic.ini" upgrade head done 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()"