version: "3.8"

services:
  api:
    image: evoapicloud/evo-ai:latest
    depends_on:
      - postgres
      - redis
    environment:
      POSTGRES_CONNECTION_STRING: postgresql://postgres:${POSTGRES_PASSWORD:-postgres}@postgres:5432/evo_ai
      REDIS_HOST: redis
      REDIS_PORT: ${REDIS_PORT:-6379}
      REDIS_PASSWORD: ${REDIS_PASSWORD:-""}
      REDIS_SSL: "false"
      REDIS_KEY_PREFIX: "a2a:"
      REDIS_TTL: 3600
      JWT_SECRET_KEY: ${JWT_SECRET_KEY}
      SENDGRID_API_KEY: ${SENDGRID_API_KEY}
      EMAIL_FROM: ${EMAIL_FROM}
      APP_URL: https://evo.api.seuadvogadoja.com.br
      LOG_LEVEL: INFO
      DEBUG: "false"
    volumes:
      - ./logs:/app/logs
      - ./static:/app/static
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/"]
      interval: 30s
      timeout: 10s
      retries: 5

  postgres:
    image: postgres:14-alpine
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
      POSTGRES_DB: evo_ai
    volumes:
      - postgres_data:/var/lib/postgresql/data

  redis:
    image: redis:alpine
    command:
      - redis-server
      - --appendonly
      - "yes"
      - --requirepass
      - "${REDIS_PASSWORD}"
    volumes:
      - redis_data:/data

volumes:
  postgres_data:
    name: evo-ai-postgres-data
  redis_data:
    name: evo-ai-redis-data
