Initial commit: FastAPI app with Loguru, PostgreSQL, and Docker Compose

Made-with: Cursor
This commit is contained in:
Kevin
2026-04-20 17:58:03 +08:00
commit d1a3d029ec
15 changed files with 834 additions and 0 deletions

31
start.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Start PostgreSQL (docker-compose.dev.yml) and run the FastAPI app with hot reload.
# Usage: ./start.sh
# Optional: SKIP_DOCKER=1 to skip Compose (use external DB). Set DATABASE_URL accordingly.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
COMPOSE_FILE="${COMPOSE_FILE:-docker-compose.dev.yml}"
if [[ "${SKIP_DOCKER:-0}" != "1" ]]; then
docker compose -f "$COMPOSE_FILE" up -d db
echo "Waiting for PostgreSQL..."
for _ in $(seq 1 60); do
if docker compose -f "$COMPOSE_FILE" exec -T db \
pg_isready -U "${POSTGRES_USER:-postgres}" -d "${POSTGRES_DB:-operation_room}" \
>/dev/null 2>&1; then
echo "PostgreSQL is ready."
break
fi
sleep 1
done
else
echo "SKIP_DOCKER=1: not starting Docker Compose; using DATABASE_URL from the environment."
fi
export DATABASE_URL="${DATABASE_URL:-postgresql+asyncpg://postgres:postgres@localhost:5432/operation_room}"
exec uv run uvicorn main:app --host "${HOST:-0.0.0.0}" --port "${PORT:-8000}" --reload