1
0

entrypoint.sh 956 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. set -eu
  3. mode="${1:-api}"
  4. # Ensure the SQLite data dir exists when DB_SQLITE_PATH is configured.
  5. if [ -n "${DB_SQLITE_PATH:-}" ]; then
  6. sqlite_dir="$(dirname "$DB_SQLITE_PATH")"
  7. mkdir -p "$sqlite_dir"
  8. fi
  9. case "$mode" in
  10. api)
  11. # Provision UI_SERVICE_TOKEN in api_tokens before serving. Idempotent;
  12. # logs a warning and skips if the env var is empty (early bring-up).
  13. cd /app
  14. php bin/console auth:bootstrap-service-token || \
  15. echo "warning: auth:bootstrap-service-token failed; continuing anyway" >&2
  16. exec frankenphp run --config /etc/Caddyfile
  17. ;;
  18. migrate)
  19. cd /app
  20. # Empty migrations dir is fine — phinx exits 0 with "no migrations to run".
  21. exec vendor/bin/phinx migrate --configuration=config/phinx.php
  22. ;;
  23. *)
  24. echo "Unknown mode: $mode" >&2
  25. echo "Usage: entrypoint.sh [api|migrate]" >&2
  26. exit 1
  27. ;;
  28. esac