version: '3'
volumes:
  ro:
  ro_db:
  mongo_db:
  mon_db:
  pol_db:
  osm_packages:
  prom_db:
networks:
  netOSM:
    external:
      name: ${OSM_NETWORK:-netosm}
    #driver: overlay
    #driver_opts:
    #  com.docker.network.driver.mtu: "1446"
services:
  zookeeper:
    image: wurstmeister/zookeeper:${ZOOKEEPER_TAG:-latest}
#    ports:
#      - "2181:2181"
    networks:
      - netOSM
    healthcheck:
      test: echo stat | nc localhost 2181
      interval: 10s
      timeout: 10s
      retries: 3
  kafka:
    image: wurstmeister/kafka:${KAFKA_TAG:-latest}
    ports:
      - "9092"
    networks:
      - netOSM
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka
      KAFKA_ADVERTISED_PORT: 9092
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LOG_RETENTION_HOURS: 24
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    #depends_on:
    #  - zookeeper
  mongo:
    image: mongo
#    ports:
#      - "27017:27017"
    networks:
      - netOSM
    volumes:
      - mongo_db:/data/db
  prometheus:
    image: prom/prometheus:${PROMETHEUS_TAG:-latest}
    hostname: prometheus
    ports:
      - "${OSM_PROM_PORTS:-9091:9090}"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - prom_db:/prometheus
    networks:
      - netOSM
  keystone:
    image: ${DOCKER_USER:-opensourcemano}/keystone:${TAG:-latest}
    networks:
      - netOSM
    environment:
      DB_HOST: mysql
    env_file:
      - ./keystone.env
    ports:
      - "${OSM_KEYSTONE_PORTS:-5000:5000}"
  nbi:
    image: ${DOCKER_USER:-opensourcemano}/nbi:${TAG:-latest}
    networks:
      - netOSM
    volumes:
      - osm_packages:/app/storage
    environment:
      OSMNBI_DATABASE_HOST: mongo
      OSMNBI_MESSAGE_HOST: kafka
    env_file:
      - ./nbi.env
    ports:
      - "${OSM_NBI_PORTS:-9999:9999}"
    #depends_on:
    #  - kafka
    #  - mongo
  lcm:
    image: ${DOCKER_USER:-opensourcemano}/lcm:${TAG:-latest}
    networks:
      - netOSM
    volumes:
      - osm_packages:/app/storage
    environment:
      OSMLCM_RO_HOST: ro
      OSMLCM_DATABASE_HOST: mongo
      OSMLCM_MESSAGE_HOST: kafka
    env_file:
      - ./lcm.env
    #depends_on:
    #  - kafka
    #  - mongo
    #  - ro
  mysql:
    image: mysql:5
    networks:
      netOSM:
        aliases:
          - ro-db
    volumes:
      - ro_db:/var/lib/mysql
    env_file:
      - ./ro-db.env
#    ports:
#      - "3306:3306"
  ro:
    image: ${DOCKER_USER:-opensourcemano}/ro:${TAG:-latest}
    networks:
      - netOSM
    environment:
      RO_DB_HOST: mysql
    env_file:
      - ./ro.env
    #depends_on:
    #  - mysql
    volumes:
      - ro:/var/log/osm
    ports:
      - "${OSM_RO_PORTS:-9090:9090}"
  mon:
    image: ${DOCKER_USER:-opensourcemano}/mon:${TAG:-latest}
    networks:
      - netOSM
    volumes:
      - mon_db:/app/database
    environment:
      OSMMON_MESSAGE_HOST: kafka
      OSMMON_MESSAGE_PORT: 9092
    env_file:
      - ./mon.env
    ports:
      - "${OSM_MON_PORTS:-8662:8662}"
    #depends_on:
    #  - kafka
    logging:
        driver: "json-file"
        options:
            max-file: 5
            max-size: 10m
  pol:
    image: ${DOCKER_USER:-opensourcemano}/pol:${TAG:-latest}
    networks:
      - netOSM
    volumes:
      - pol_db:/app/database
    environment:
      OSMPOL_MESSAGE_HOST: kafka
      OSMPOL_MESSAGE_PORT: 9092
    env_file:
      - ./pol.env
    #depends_on:
    #  - kafka
    #  - mon
    logging:
      driver: "json-file"
      options:
        max-file: 5
        max-size: 10m
  light-ui:
    image: ${DOCKER_USER:-opensourcemano}/light-ui:${TAG:-latest}
    networks:
      - netOSM
    environment:
      OSM_SERVER: nbi
    #depends_on:
    #  - nbi
    ports:
      - "${OSM_UI_PORTS:-80:80}"
