# /opt/docker/dev/service_finder/docker-compose.yml
services:
  # --- ADATBÁZIS ÉS API ---
  migrate:
    build: ./backend
    container_name: sf_migrate
    env_file: .env
    volumes:
      - ./backend:/app
      - /opt/docker/scripts:/opt/docker/scripts
    command: >
      bash -c "sleep 5 && alembic upgrade head && PYTHONPATH=/app python -m app.tests_internal.fixes.final_admin_fix"
    networks:
      - sf_net
      - shared_db_net
    restart: "no"

  api:
    build: ./backend
    container_name: sf_api
    env_file: .env
    ports:
      - "8000:8000"
    volumes:
      - ./backend:/app
      - /mnt/nas/app_data:/mnt/nas/app_data
      - ./static_previews:/app/static/previews
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

              
  # --- SZERVIZ HADOSZTÁLY ---
  service_scout:
    build: ./backend
    container_name: sf_service_scout
    command: python -u -m app.workers.service.service_robot_1_scout_osm
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  service_hunter:
    build: ./backend
    container_name: sf_service_hunter
    command: python -u -m app.workers.service.service_robot_0_hunter
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped
    # profiles: ["disabled"] # Ezzel a sorral letilthatod, hogy automatikusan elinduljon!

  
  service_researcher:
    build: ./backend
    command: python -u -m app.workers.service.service_robot_2_researcher
    deploy:
      replicas: 2
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  service_enricher:
    build: ./backend
    container_name: sf_service_enricher
    command: python -u -m app.workers.service.service_robot_3_enricher
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  service_validator:
    build: ./backend
    container_name: sf_service_validator
    command: python -u -m app.workers.service.service_robot_4_validator_google
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  # --- JÁRMŰ HADOSZTÁLY ---
  vehicle_discovery:
    build: ./backend
    container_name: sf_vehicle_discovery
    command: python -u -m app.workers.vehicle.vehicle_robot_0_discovery_engine
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  vehicle_hunter:
    build: ./backend
    container_name: sf_vehicle_hunter
    command: python -u -m app.workers.vehicle.vehicle_robot_1_catalog_hunter
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  sf_nhtsa_hunter:
    build: ./backend
    container_name: sf_nhtsa_hunter
    command: python -m app.workers.vehicle.vehicle_robot_1_2_nhtsa_fetcher
    env_file: .env
    restart: unless-stopped
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net

  sf_bike_hunter:
    build: ./backend
    container_name: sf_bike_hunter
    command: python -m app.workers.vehicle.vehicle_robot_1_4_bike_hunter
    env_file: .env
    restart: unless-stopped
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net

  vehicle_researcher:
    build: ./backend
    # container_name: sf_vehicle_researcher
    command: python -u -m app.workers.vehicle.vehicle_robot_2_researcher
    deploy:
      replicas: 2
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  sf_heavy_eu:
    build: ./backend
    container_name: sf_heavy_eu
    command: python -m app.workers.vehicle.vehicle_robot_1_5_heavy_eu
    env_file: .env
    restart: unless-stopped
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net

  vehicle_alchemist:
    build: ./backend
    container_name: sf_vehicle_alchemist
    command: python -u -m app.workers.vehicle.vehicle_robot_3_alchemist_pro
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  vehicle_vin_auditor:
    build: ./backend
    container_name: sf_vehicle_vin_auditor
    command: python -u -m app.workers.vehicle.vehicle_robot_4_vin_auditor
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  # --- GB (ANGOL) JÁRMŰ HADOSZTÁLY ---
  gb_vehicle_discovery:
    build: ./backend
    container_name: sf_gb_vehicle_discovery
    command: python -u -m app.workers.vehicle.vehicle_robot_0_gb_discovery
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  gb_vehicle_hunter:
    build: ./backend
    container_name: sf_gb_vehicle_hunter
    command: python -u -m app.workers.vehicle.vehicle_robot_1_gb_hunter
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

  # --- RENDSZER HADOSZTÁLY ---
  system_ocr:
    build: ./backend
    container_name: sf_system_ocr
    command: python -u -m app.workers.ocr.robot_1_ocr_processor
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    volumes:
      - /mnt/nas/app_data:/mnt/nas/app_data
    restart: unless-stopped

  system_auditor:
    build: ./backend
    container_name: sf_system_auditor
    command: python -u -m app.workers.system.system_robot_2_service_auditor
    env_file: .env
    depends_on:
      migrate:
        condition: service_completed_successfully
    networks:
      - sf_net
      - shared_db_net
    restart: unless-stopped

networks:
  sf_net:
    driver: bridge
  shared_db_net:
    external: true