---
volumes:
  akvorado-clickhouse-keeper-db-1:
  akvorado-clickhouse-keeper-db-2:
  akvorado-clickhouse-keeper-db-3:
  akvorado-clickhouse-keeper-1:
  akvorado-clickhouse-keeper-2:
  akvorado-clickhouse-keeper-3:
  akvorado-clickhouse-2:
  akvorado-clickhouse-3:
  akvorado-clickhouse-4:

services:
  akvorado-orchestrator:
    environment:
      AKVORADO_CFG_ORCHESTRATOR_CLICKHOUSE_CLUSTER: akvorado

  clickhouse-keeper-1: &clickhouse-keeper
    extends:
      file: versions.yml
      service: clickhouse-keeper
    restart: unless-stopped
    expose:
      - 9100/tcp
    volumes:
      - akvorado-clickhouse-keeper-db-1:/var/lib/clickhouse-keeper
      - akvorado-clickhouse-keeper-1:/var/lib/clickhouse
      - ./clickhouse/observability:/etc/clickhouse-keeper/keeper_config.d/observability.xml
      - ./clickhouse/keeper.xml:/etc/clickhouse-keeper/keeper_config.d/akvorado.xml
      - ./clickhouse/keeper-cluster.xml:/etc/clickhouse-keeper/keeper_config.d/keeper-cluster.xml
      - ./clickhouse/keeper-cluster.xml:/etc/clickhouse-keeper/keeper_config.d/keeper-cluster-1.xml
    healthcheck:
      interval: 20s
      test: ["CMD", "wget", "-T", "1", "--spider", "--no-proxy", "http://127.0.0.1:9100/metrics"]
    labels:
      - metrics.port=9100
  clickhouse-keeper-2:
    <<: *clickhouse-keeper
    volumes:
      - akvorado-clickhouse-keeper-db-2:/var/lib/clickhouse-keeper
      - akvorado-clickhouse-keeper-2:/var/lib/clickhouse
      - ./clickhouse/observability:/etc/clickhouse-keeper/keeper_config.d/observability.xml
      - ./clickhouse/keeper.xml:/etc/clickhouse-keeper/keeper_config.d/akvorado.xml
      - ./clickhouse/keeper-cluster.xml:/etc/clickhouse-keeper/keeper_config.d/keeper-cluster.xml
      - ./clickhouse/keeper-cluster.xml:/etc/clickhouse-keeper/keeper_config.d/keeper-cluster-2.xml
  clickhouse-keeper-3:
    <<: *clickhouse-keeper
    volumes:
      - akvorado-clickhouse-keeper-db-3:/var/lib/clickhouse-keeper
      - akvorado-clickhouse-keeper-3:/var/lib/clickhouse
      - ./clickhouse/observability:/etc/clickhouse-keeper/keeper_config.d/observability.xml
      - ./clickhouse/keeper.xml:/etc/clickhouse-keeper/keeper_config.d/akvorado.xml
      - ./clickhouse/keeper-cluster.xml:/etc/clickhouse-keeper/keeper_config.d/keeper-cluster.xml
      - ./clickhouse/keeper-cluster.xml:/etc/clickhouse-keeper/keeper_config.d/keeper-cluster-3.xml

  clickhouse:
    depends_on:
      - clickhouse-keeper-1
      - clickhouse-keeper-2
      - clickhouse-keeper-3
    volumes:
      - ./clickhouse/cluster.xml:/etc/clickhouse-server/config.d/cluster.xml
      - ./clickhouse/cluster-1.xml:/etc/clickhouse-server/config.d/cluster-1.xml
  clickhouse-2:
    extends:
      file: docker-compose.yml
      service: clickhouse
    depends_on:
      - clickhouse-keeper-1
      - clickhouse-keeper-2
      - clickhouse-keeper-3
    volumes:
      - ./clickhouse/cluster.xml:/etc/clickhouse-server/config.d/cluster.xml
      - ./clickhouse/cluster-2.xml:/etc/clickhouse-server/config.d/cluster-2.xml
      - akvorado-clickhouse-2:/var/lib/clickhouse
  clickhouse-3:
    extends:
      file: docker-compose.yml
      service: clickhouse
    depends_on:
      - clickhouse-keeper-1
      - clickhouse-keeper-2
      - clickhouse-keeper-3
    volumes:
      - ./clickhouse/cluster.xml:/etc/clickhouse-server/config.d/cluster.xml
      - ./clickhouse/cluster-3.xml:/etc/clickhouse-server/config.d/cluster-3.xml
      - akvorado-clickhouse-3:/var/lib/clickhouse
  clickhouse-4:
    extends:
      file: docker-compose.yml
      service: clickhouse
    depends_on:
      - clickhouse-keeper-1
      - clickhouse-keeper-2
      - clickhouse-keeper-3
    volumes:
      - ./clickhouse/cluster.xml:/etc/clickhouse-server/config.d/cluster.xml
      - ./clickhouse/cluster-4.xml:/etc/clickhouse-server/config.d/cluster-4.xml
      - akvorado-clickhouse-4:/var/lib/clickhouse
