version: '3.8'

services:
  # Base de données PostgreSQL
  db:
    image: postgres:15
    environment:
      POSTGRES_DB: donshare_db
      POSTGRES_USER: donshare_user
      POSTGRES_PASSWORD: donshare_password
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U donshare_user -d donshare_db"]
      interval: 10s
      timeout: 5s
      retries: 5

  # API FastAPI
  api:
    build: .
    environment:
      DATABASE_URL: postgresql://donshare_user:donshare_password@db:5432/donshare_db
      SECRET_KEY: your-secret-key-change-in-production
      DEBUG: "true"
      CORS_ORIGINS: http://localhost:3000,http://localhost:3001
    ports:
      - "8000:8000"
    depends_on:
      db:
        condition: service_healthy
    volumes:
      - ./uploads:/app/uploads
    restart: unless-stopped

  # Redis (optionnel, pour le cache)
  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    restart: unless-stopped

volumes:
  postgres_data:
  redis_data:
