version: "3.8"

services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: videogen
      POSTGRES_PASSWORD: videogen
      POSTGRES_DB: videogen
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    volumes:
      - redisdata:/data

  api:
    build: .
    command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
    ports:
      - "8000:8000"
    volumes:
      - .:/app
    env_file:
      - .env
    environment:
      DATABASE_URL: postgresql+asyncpg://videogen:videogen@postgres:5432/videogen
      REDIS_URL: redis://redis:6379/0
    depends_on:
      - postgres
      - redis

  worker:
    build: .
    command: celery -A app.tasks.celery_app worker -l info
    volumes:
      - .:/app
    env_file:
      - .env
    environment:
      DATABASE_URL: postgresql+asyncpg://videogen:videogen@postgres:5432/videogen
      REDIS_URL: redis://redis:6379/0
    depends_on:
      - postgres
      - redis

volumes:
  pgdata:
  redisdata:
