version: "2"
services:
  rabbitmq_dc:
    image: rabbitmq:3.9.5-management-alpine
    healthcheck:
      test: rabbitmq-diagnostics -q ping
      interval: 30s
      timeout: 30s
      retries: 3
    restart: always
    environment:
      - RABBITMQ_DEFAULT_USER=${MIDDLEWARE_USER}
      - RABBITMQ_DEFAULT_PASS=${MIDDLEWARE_PASSWORD}
    ports:
      - ${MIDDLEWARE_EXTERNAL_PORT}:15672
      - ${MIDDLEWARE_PORT}:5672
    volumes:
      - rabbitmq_data:/var/lib/rabbitmq/mnesia/
      - rabbitmq_logs:/var/log/rabbitmq/
    networks:
      - aifw_net

  osd_ava:
    image: osd_ava:${TAG}
    restart: always
    build: 
      context: https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/osd_ava.git
      dockerfile: Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - AI_FW_DIR=${AI_FW_DIR}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target:  ${AI_FW_DIR}
      - type: volume
        source: osd_ava_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy

  osd_ave:
    image: osd_ave:${TAG}
    restart: always
    build: 
      context: https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/osd_ave.git
      dockerfile: Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - AI_FW_DIR=${AI_FW_DIR}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target:  ${AI_FW_DIR}
      - type: volume
        source: osd_ave_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy

  osd_avs:
    image: osd_avs:${TAG}
    restart: always
    build:
      context: https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/osd_avs.git
      dockerfile: Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - AI_FW_DIR=${AI_FW_DIR}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target:  ${AI_FW_DIR}
      - type: volume
        source: osd_avs_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy

  mmc_asr:
    image: mmc_asr:${TAG}
    restart: always
    build: 
      context: https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/mmc_asr.git
      dockerfile: Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - AI_FW_DIR=${AI_FW_DIR}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              device_ids: ['0']
              capabilities: [gpu]
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target: ${AI_FW_DIR}
      - type: volume
        source: mmc_asr_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy

  osd_tvs:
    image: osd_tvs:${TAG}
    restart: always
    build: 
      context: https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/osd_tvs.git
      dockerfile: Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - AI_FW_DIR=${AI_FW_DIR}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target: ${AI_FW_DIR}
      - type: volume
        source: osd_tvs_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy

  controller:
    image: controller:${TAG}
    restart: always
    build: 
      context: ./     
      dockerfile: controller/Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target:  ${AI_FW_DIR}
      - type: volume
        source: controller_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy


  mmc_aus:
    image: mmc_aus:${TAG}
    restart: always
    build:
      context: https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/mmc_aus.git
      dockerfile: Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - AI_FW_DIR=${AI_FW_DIR}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - HUGGINGFACE_TOKEN=${HUGGINGFACE_TOKEN}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              device_ids: ['0']
              capabilities: [gpu]
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target: ${AI_FW_DIR}
      - type: volume
        source: mmc_aus_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy

  paf_fir:
    image: paf_fir:${TAG}
    restart: always
    build: 
      context: https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/paf_fir.git
      dockerfile: Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - AI_FW_DIR=${AI_FW_DIR}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              device_ids: ['0']
              capabilities: [gpu]
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target: ${AI_FW_DIR}
      - type: volume
        source: paf_fir_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy

  osd_vcd:
    image: osd_vcd:${TAG}
    restart: always
    build: 
      context: https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/osd_vcd.git
      dockerfile: Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - AI_FW_DIR=${AI_FW_DIR}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target: ${AI_FW_DIR}
      - type: volume
        source: vcd_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy

  mmc_sir:
    image: mmc_sir:${TAG}
    restart: always
    build: 
      context: https://${GIT_NAME}:${GIT_TOKEN}@experts.mpai.community/software/mpai-aif/osd_tma/mmc_sir.git
      dockerfile: Dockerfile
      args:
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    environment:
      - LOG_LEVEL=${LOG_LEVEL}
      - AI_FW_DIR=${AI_FW_DIR}
      - MIDDLEWARE_USER=${MIDDLEWARE_USER}
      - MIDDLEWARE_PASSWORD=${MIDDLEWARE_PASSWORD}
      - MIDDLEWARE_VIRTUALHOST=${MIDDLEWARE_VIRTUALHOST}
      - MIDDLEWARE_PORT=${MIDDLEWARE_PORT}
      - GIT_NAME=${GIT_NAME}
      - GIT_TOKEN=${GIT_TOKEN}
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              device_ids: ['0']
              capabilities: [gpu]
    volumes:
      - type: bind
        source: ${PATH_SHARED}
        target: ${AI_FW_DIR}
      - type: volume
        source: mmc_sir_logs
        target: /LOGS
    networks:
      - aifw_net
    depends_on:
      rabbitmq_dc:
        condition: service_healthy


volumes:
  rabbitmq_data:
    driver: local
  rabbitmq_logs:
    driver: local
  controller_logs:
    driver: local
  osd_ava_logs:
    driver: local
  osd_ave_logs:
    driver: local
  osd_avs_logs:
    driver: local
  mmc_asr_logs:
    driver: local
  osd_tvs_logs:
    driver: local
  mmc_aus_logs:
    driver: local
  paf_fir_logs:
    driver: local
  vcd_logs:
    driver: local
  mmc_sir_logs:
    driver: local

networks:
  aifw_net:
    driver: bridge