services:
  postgres:
    image: pgvector/pgvector:pg16
    container_name: audio_classifier_db
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-audio_user}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-audio_password}
      POSTGRES_DB: ${POSTGRES_DB:-audio_classifier}
    ports:
      - "5433:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./backend/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-audio_user}"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  backend:
    image: git.benoitsz.com/benoit/audio-classifier-backend:dev
    container_name: audio_classifier_api
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      DATABASE_URL: postgresql://${POSTGRES_USER:-audio_user}:${POSTGRES_PASSWORD:-audio_password}@postgres:5432/${POSTGRES_DB:-audio_classifier}
      CORS_ORIGINS: ${CORS_ORIGINS:-*}
      ANALYSIS_USE_CLAP: ${ANALYSIS_USE_CLAP:-false}
      ANALYSIS_NUM_WORKERS: ${ANALYSIS_NUM_WORKERS:-4}
      ESSENTIA_MODELS_PATH: /app/models
      # Authentication
      ADMIN_EMAIL: ${ADMIN_EMAIL:-admin@example.com}
      ADMIN_PASSWORD: ${ADMIN_PASSWORD:-changeme}
      JWT_SECRET_KEY: ${JWT_SECRET_KEY:-your-secret-key-change-in-production}
      JWT_EXPIRATION_HOURS: ${JWT_EXPIRATION_HOURS:-24}
    ports:
      - "8001:8000"
    volumes:
      # Mount your audio library (read-write for transcoding and waveforms)
      - ${AUDIO_LIBRARY_PATH:-./audio_samples}:/audio
    restart: unless-stopped

  frontend:
    image: git.benoitsz.com/benoit/audio-classifier-frontend:dev
    container_name: audio_classifier_ui
    environment:
      NEXT_PUBLIC_API_URL: https://api.audioclassifier.benoitsz.com
    ports:
      - "3000:3000"
    depends_on:
      - backend
    restart: unless-stopped

volumes:
  postgres_data:
    driver: local
