services:
  db:
    image: postgres:16
    environment:
      POSTGRES_DB: secureflow
      POSTGRES_USER: secureflow
      POSTGRES_PASSWORD: secureflow
    ports: ["54329:5432"]
    volumes: [pgdata:/var/lib/postgresql/data]
  redis:
    image: redis:7
    ports: ["63799:6379"]
  api:
    build: ./backend
    env_file: .env.example
    environment:
      DATABASE_URL: postgresql+psycopg://secureflow:secureflow@db:5432/secureflow
      LOCAL_STORAGE_PATH: /data/uploads
    volumes:
      - ./backend:/app
      - uploads:/data/uploads
    ports: ["8008:8000"]
    depends_on: [db, redis]
    command: bash -lc "alembic upgrade head && python -m app.seed && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
  frontend:
    build: ./frontend
    environment:
      VITE_API_URL: http://localhost:8008
    volumes:
      - ./frontend:/app
      - /app/node_modules
    ports: ["5173:5173"]
    depends_on: [api]
volumes:
  pgdata:
  uploads:
