# ============================================================ # StudIQ Backend — Local Development Stack # ============================================================ # Starts PostgreSQL, Redis, and the API server. # Usage: docker compose up --build # ============================================================ services: # ── PostgreSQL Database ────────────────────────────────── postgres: image: postgres:16-alpine environment: POSTGRES_USER: studiq POSTGRES_PASSWORD: studiq POSTGRES_DB: studiq ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U studiq"] interval: 5s timeout: 3s retries: 5 # ── Redis Cache ────────────────────────────────────────── redis: image: redis:7-alpine ports: - "6379:6379" healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 5 # ── FastAPI Backend ────────────────────────────────────── api: build: . ports: - "8000:8000" env_file: - .env environment: # Override database URLs to point to Docker service names DATABASE_URL: postgresql+asyncpg://studiq:studiq@postgres:5432/studiq REDIS_URL: redis://redis:6379 depends_on: postgres: condition: service_healthy redis: condition: service_healthy volumes: - .:/app command: > sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload" volumes: pgdata: