version: '3'
services:
  cassandra:
    image: cassandra:4.1.1
    ports:
      - "9042:9042"
    environment:
      - "MAX_HEAP_SIZE=256M"
      - "HEAP_NEWSIZE=128M"
    healthcheck:
      test: ["CMD", "cqlsh", "-u cassandra", "-p cassandra" ,"-e describe keyspaces"]
      interval: 15s
      timeout: 30s
      retries: 10
  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus:/etc/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
    ports:
      - '9090:9090'
  node-exporter:
    image: prom/node-exporter
    ports:
      - '9100:9100'
  cadence:
    image: ubercadence/server:master-auto-setup
    ports:
     - "8000:8000"
     - "8001:8001"
     - "8002:8002"
     - "8003:8003"
     - "7933:7933"
     - "7934:7934"
     - "7935:7935"
     - "7939:7939"
     - "7833:7833"
    environment:
      - "ASYNC_WF_KAFKA_QUEUE_ENABLED=true"
      - "ASYNC_WF_KAFKA_QUEUE_TOPIC=async-wf-topic1"
      - "KAFKA_SEEDS=kafka"
      - "KAFKA_PORT=9092"
      - "ZOOKEEPER_SEEDS=zookeeper"
      - "ZOOKEEPER_PORT=2181"
      - "CASSANDRA_SEEDS=cassandra"
      - "PROMETHEUS_ENDPOINT_0=0.0.0.0:8000"
      - "PROMETHEUS_ENDPOINT_1=0.0.0.0:8001"
      - "PROMETHEUS_ENDPOINT_2=0.0.0.0:8002"
      - "PROMETHEUS_ENDPOINT_3=0.0.0.0:8003"
      - "DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development.yaml"
      - "LOG_LEVEL=debug"
    depends_on:
      cassandra:
        condition: service_healthy
      prometheus:
        condition: service_started
      kafka:
        condition: service_started
  cadence-web:
    image: ubercadence/web:latest
    environment:
      - "CADENCE_TCHANNEL_PEERS=cadence:7933"
    ports:
      - "8088:8088"
    depends_on:
      - cadence
  grafana:
    image: grafana/grafana
    volumes:
      - ./grafana:/etc/grafana
    user: "1000"
    depends_on:
      - prometheus
    ports:
      - '3000:3000'
  zookeeper:
    image: wurstmeister/zookeeper:3.4.6
    ports:
      - "2181:2181"
  kafka:
    image: wurstmeister/kafka:2.12-2.1.1
    depends_on:
      - zookeeper
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      # create a topic with 10 partitions and 1 replica
      # topic name must match ASYNC_WF_KAFKA_QUEUE_TOPIC specified in cadence container above
      KAFKA_CREATE_TOPICS: "async-wf-topic1:10:1"
