services:
  clickhouse1:
    image: 'clickhouse/clickhouse-server:${CLICKHOUSE_VERSION-25.12-alpine}'
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    hostname: clickhouse1
    container_name: clickhouse-server-node-1
    environment:
      CLICKHOUSE_SKIP_USER_SETUP: 1
    ports:
      - '8124:8123'
      - '9002:9000'
      - '9181:9181'
    volumes:
      - './.docker/clickhouse/cluster/server1_config.xml:/etc/clickhouse-server/config.xml'
      - './.docker/clickhouse/cluster/server1_macros.xml:/etc/clickhouse-server/config.d/macros.xml'
      - './.docker/clickhouse/users.xml:/etc/clickhouse-server/users.xml'

  clickhouse2:
    image: 'clickhouse/clickhouse-server:${CLICKHOUSE_VERSION-25.12-alpine}'
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    hostname: clickhouse2
    container_name: clickhouse-server-node-2
    environment:
      CLICKHOUSE_SKIP_USER_SETUP: 1
    ports:
      - '8125:8123'
      - '9001:9000'
      - '9182:9181'
    volumes:
      - './.docker/clickhouse/cluster/server2_config.xml:/etc/clickhouse-server/config.xml'
      - './.docker/clickhouse/cluster/server2_macros.xml:/etc/clickhouse-server/config.d/macros.xml'
      - './.docker/clickhouse/users.xml:/etc/clickhouse-server/users.xml'

  # Using Nginx as a cluster entrypoint and a round-robin load balancer for HTTP requests
  nginx:
    image: 'nginx:1.23.1-alpine'
    hostname: nginx
    container_name: clickhouse-go-nginx
    ports:
      - '8123:8123'
      - '9000:9000'
    volumes:
      - './.docker/nginx/http.conf:/etc/nginx/conf.d/http.conf'
      - './.docker/nginx/tcp.conf:/etc/nginx/conf.d/tcp.conf'
      - './.docker/nginx/nginx.conf:/etc/nginx/nginx.conf'
