version: "3.8"
services:
  postgres:
    build: ./postgres
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 10s
      timeout: 5s
      retries: 5

  minio:
    image: minio/minio:latest
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER: ${MINIO_ROOT_USER}
      MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
    volumes:
      - miniodata:/data
    ports:
      - "9000:9000"
      - "9001:9001"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  voice-agent:
    build: ./voice_agent
    ports:
      - "8000:8000"
    environment:
      MINIO_ENDPOINT: "http://minio:9000"
      MINIO_ACCESS_KEY: "${MINIO_ROOT_USER}"
      MINIO_SECRET_KEY: "${MINIO_ROOT_PASSWORD}"
      OPENAI_API_KEY: "${OPENAI_API_KEY}"
      MINIO_BUCKET: "${MINIO_BUCKET}"
      POSTGRES_HOST: "postgres"
      POSTGRES_USER: "${POSTGRES_USER}"
      POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
      POSTGRES_DB: "${POSTGRES_DB}"
      DB_PORT: "${DB_PORT}"
      DB_HOST: "${DB_HOST}"
      TTS_PROVIDER: "${TTS_PROVIDER}"
      CUSTOM_TTS_URL: "${CUSTOM_TTS_URL}"
    depends_on:
      - minio
      - postgres

volumes:
  pgdata:
  miniodata: