version: '3.3'
services:
  cvat_elasticsearch:
    container_name: cvat_elasticsearch
    image: cvat_elasticsearch
    networks:
      default:
        aliases:
          - elasticsearch
    build:
      context: ./components/analytics/elasticsearch
      args:
        ELK_VERSION: 6.4.0
    volumes:
      - cvat_events:/usr/share/elasticsearch/data
    restart: always

  cvat_kibana:
    container_name: cvat_kibana
    image: cvat_kibana
    networks:
      default:
        aliases:
          - kibana
    build:
      context: ./components/analytics/kibana
      args:
        ELK_VERSION: 6.4.0
    depends_on: ['cvat_elasticsearch']
    restart: always

  cvat_kibana_setup:
    container_name: cvat_kibana_setup
    image: cvat/server
    volumes: ['./components/analytics/kibana:/home/django/kibana:ro']
    depends_on: ['cvat']
    working_dir: '/home/django'
    entrypoint:
      [
        'bash',
        'wait-for-it.sh',
        'elasticsearch:9200',
        '-t',
        '0',
        '--',
        '/bin/bash',
        'wait-for-it.sh',
        'kibana:5601',
        '-t',
        '0',
        '--',
        'python3',
        'kibana/setup.py',
        'kibana/export.json',
      ]
    environment:
      no_proxy: elasticsearch,kibana,${no_proxy}

  cvat_logstash:
    container_name: cvat_logstash
    image: cvat_logstash
    networks:
      default:
        aliases:
          - logstash
    build:
      context: ./components/analytics/logstash
      args:
        ELK_VERSION: 6.4.0
        http_proxy: ${http_proxy}
        https_proxy: ${https_proxy}
    depends_on: ['cvat_elasticsearch']
    restart: always

  cvat:
    environment:
      DJANGO_LOG_SERVER_HOST: logstash
      DJANGO_LOG_SERVER_PORT: 5000
      DJANGO_LOG_VIEWER_HOST: kibana
      DJANGO_LOG_VIEWER_PORT: 5601
      CVAT_ANALYTICS: 1
      no_proxy: kibana,logstash,nuclio,${no_proxy}

volumes:
  cvat_events:
