#####################################################
### PLEASE, CONFIGURE MONITOR-ADAPTER ENVIRONMENT ###
#####################################################

version: "3.3"
services:
  monitor-adapter:
    image: beia/monitoring_adapter
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
      placement:
        constraints: [node.role == manager]
    environment:
      - MONITORING_SERVER=10.128.19.62
      - MONITORING_PREFIX=eu.switch.wt
    hostname: monitor-adapter
    networks:
      uc-ol:
        aliases:
          - monitor-adapter

  mongo:
    image: wtelecom/mongo:switch
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
      placement:
        constraints: [node.role == manager]
    depends_on:
      - monitor-adapter
    volumes:
      - mongo-volume:/data/db
    hostname: mongo
    networks:
      uc-ol:
        aliases:
          - mongo

  redis:
    image: redis:4.0-alpine
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
      placement:
        constraints: [node.role == manager]
    depends_on:
      - monitor-adapter
    volumes:
      - redis-volume:/data
    hostname: redis
    networks:
      uc-ol:
        aliases:
          - redis

  db:
    image: wtelecom/mysql:switch
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
      placement:
        constraints: [node.role == manager]
    depends_on:
      - monitor-adapter
    environment:
      - MYSQL_ROOT_PASSWORD=supersecret
    volumes:
      - db-volume:/var/lib/mysql
    hostname: db
    networks:
      uc-ol:
        aliases:
          - db

  # asterisk:
  #   image: wtelecom/asterisk:switch
  #   deploy:
  #     replicas: 1
  #     update_config:
  #       parallelism: 1
  #       delay: 10s
  #     restart_policy:
  #       condition: any
  #   depends_on:
  #     - monitor-adapter
  #     - db
  #   hostname: asterisk
  #   networks:
  #     uc-ol:
  #       aliases:
  #         - asterisk

  doubango:
    image: wtelecom/doubango:switch
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
    depends_on:
      - monitor-adapter
      - db
    hostname: doubango
    networks:
      uc-ol:
        aliases:
          - doubango

  kamailio:
    image: wtelecom/kamailio:switch
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
      placement:
        constraints: [node.role == manager]
    depends_on:
      - monitor-adapter
      - db
#      - asterisk
      - doubango
    environment:
      - SUBNET_OVERLAY=192.168.2.0
    volumes:
      - /etc/hostname:/docker-entrypoint/hostname:ro
    ports:
      - target: 5060
        published: 5060
        protocol: udp
        mode: host
      - target: 5061
        published: 5061
        protocol: udp
        mode: host
      - target: 443
        published: 443
        protocol: tcp
        mode: host
      - target: 80
        published: 80
        protocol: tcp
        mode: host
    hostname: kamailio
    networks:
      uc-ol:
        aliases:
          - kamailio

  rtpengine:
    image: wtelecom/rtpengine:switch
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
    depends_on:
      - monitor-adapter
      - db
      - kamailio
    environment:
      - PORT_MAX=10007
      - PORT_MIN=10000
      - SUBNET_OVERLAY=192.168.2.0
      - BRIDGE_MODE=YES
    volumes:
      - /etc/hostname:/docker-entrypoint/hostname:ro
    ports:
      - target: 10000
        published: 10000
        protocol: udp
        mode: host
      - target: 10001
        published: 10001
        protocol: udp
        mode: host
      - target: 10002
        published: 10002
        protocol: udp
        mode: host
      - target: 10003
        published: 10003
        protocol: udp
        mode: host
      - target: 10004
        published: 10004
        protocol: udp
        mode: host
      - target: 10005
        published: 10005
        protocol: udp
        mode: host
      - target: 10006
        published: 10006
        protocol: udp
        mode: host
      - target: 10007
        published: 10007
        protocol: udp
        mode: host
    networks:
      uc-ol:
        aliases:
          - rtpengine

  webportalbackend:
    image: wtelecom/webportalbackend:switch
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
    depends_on:
      - monitor-adapter
      - redis
      - mongo
      - kamailio
      - rtpengine
    ports:
      - "3000:3000"
    volumes:
      - /etc/hostname:/docker-entrypoint/hostname:ro
    hostname: webportalbackend
    networks:
      uc-ol:
        aliases:
          - webportalbackend

  webportal:
    image: wtelecom/webportal:switch
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: any
    depends_on:
      - monitor-adapter
      - kamailio
      - rtpengine
      - webportalbackend
    ports:
      - "4200:4200"
    volumes:
      - /etc/hostname:/docker-entrypoint/hostname:ro
    hostname: webportal
    networks:
      uc-ol:
        aliases:
          - webportal

volumes:
  db-volume:
  redis-volume:
  mongo-volume:

networks:
  uc-ol:
    driver: overlay
    ipam:
      driver: default
      config:
        - subnet: 192.168.2.0/24
