version: "3.0"

services:
  rabbitmq:
    image: rabbitmq:3-management
    volumes:
      - rabbitmq:/var/lib/rabbitmq
    ports:
      - 15672:15672
      - 5672:5672
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "1.00"
          memory: 2G

  metadata-processor:
    build: .
    image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/indexers/metadata-and-data:${TAG}
    command: python workers/metadata_processor.py --host rabbitmq --exchange download_data_grandlyon_com_index --queue metadata_records_to_process --loglevel DEBUG
    volumes:
      #- ./config.yaml:/app/config.yaml:ro
      - working-directory:/app/output
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "1.00"

  doc-enricher:
    build: .
    image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/indexers/metadata-and-data:${TAG}
    command: python workers/doc_enricher.py --host rabbitmq --exchange download_data_grandlyon_com_index --queue doc_pages_to_enrich --loglevel DEBUG
    # volumes:
    #   - ./config.yaml:/app/config.yaml:ro
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "0.4"

  doc-processor:
    build: .
    image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/indexers/metadata-and-data:${TAG}
    command: python workers/doc_processor.py --host rabbitmq --exchange download_data_grandlyon_com_index --queue doc_pages_to_process --loglevel DEBUG
    volumes:
      #  - ./config.yaml:/app/config.yaml:ro
      - working-directory:/app/output
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "1.0" #0.5

  doc-indexer:
    build: .
    image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/indexers/metadata-and-data:${TAG}
    command: python workers/doc_indexer.py --host rabbitmq --exchange download_data_grandlyon_com_index --queue doc_pages_to_index --loglevel DEBUG
    # volumes:
    #   - ./config.yaml:/app/config.yaml:ro
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "1.0"

  reindexer:
    build: .
    image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/indexers/metadata-and-data:${TAG}
    command: python workers/reindexer.py --host rabbitmq --exchange download_data_grandlyon_com_index --queue reindex_tasks --loglevel DEBUG
    volumes:
      - working-directory:/app/output
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "1.0"

  sampler:
    build: .
    image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/indexers/metadata-and-data:${TAG}
    command: python workers/sample_generator.py --host rabbitmq --exchange download_data_grandlyon_com_index --queue sampling_tasks --loglevel DEBUG
    volumes:
      - working-directory:/app/output
    restart: unless-stopped
    deploy:
      resources:
        limits:
          cpus: "1.0"

  api:
    build: .
    image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/indexers/metadata-and-data:${TAG}
    environment:
      LOGLEVEL: DEBUG
      RMQ_HOST: rabbitmq
      RMQ_EXCHANGE: download_data_grandlyon_com_index
    command: gunicorn --workers=2 --bind=0.0.0.0:8000 --preload api:api
    volumes:
      - ${PWD}/config.yaml:/app/config.yaml:ro
      - working-directory:/app/output
    ports:
      - ${API_PORT}:8000
    restart: unless-stopped

volumes:
  rabbitmq:
  working-directory:
