---
version: '2.2'

x-shared-environment: &shared-env
  SERVER_HOST: ${DINGO_HOST_IP}
  RAFT_HOST: ${DINGO_HOST_IP}
  COOR_RAFT_PEERS: ${DINGO_HOST_IP}:22101,${DINGO_HOST_IP}:22102,${DINGO_HOST_IP}:22103
  COOR_SRV_PEERS: ${DINGO_HOST_IP}:22001,${DINGO_HOST_IP}:22002,${DINGO_HOST_IP}:22003

services:
  coordinator1:
    image: dingodatabase/dingo-store:latest
    hostname: coordinator1
    container_name: coordinator1
    network_mode: host
    environment:
      FLAGS_role: coordinator
      COORDINATOR_SERVER_START_PORT: 22001
      COORDINATOR_RAFT_START_PORT: 22101
      INSTANCE_START_ID: 1001
      <<: *shared-env

  coordinator2:
    image: dingodatabase/dingo-store:latest
    hostname: coordinator2
    container_name: coordinator2
    network_mode: host
    environment:
      FLAGS_role: coordinator
      COORDINATOR_SERVER_START_PORT: 22002
      COORDINATOR_RAFT_START_PORT: 22102
      INSTANCE_START_ID: 1002
      <<: *shared-env

  coordinator3:
    image: dingodatabase/dingo-store:latest
    hostname: coordinator3
    container_name: coordinator3
    network_mode: host
    environment:
      FLAGS_role: coordinator
      COORDINATOR_SERVER_START_PORT: 22003
      COORDINATOR_RAFT_START_PORT: 22103
      INSTANCE_START_ID: 1003
      <<: *shared-env

  store1:
    image: dingodatabase/dingo-store:latest
    hostname: store1
    container_name: store1
    network_mode: host
    depends_on:
      - coordinator1
      - coordinator2
      - coordinator3
    environment:
      FLAGS_role: store
      RAFT_START_PORT: 20101
      SERVER_START_PORT: 20001
      INSTANCE_START_ID: 1001
      <<: *shared-env

  store2:
    image: dingodatabase/dingo-store:latest
    hostname: store2
    container_name: store2
    network_mode: host
    depends_on:
      - coordinator1
      - coordinator2
      - coordinator3
    environment:
      FLAGS_role: store
      RAFT_START_PORT: 20102
      SERVER_START_PORT: 20002
      INSTANCE_START_ID: 1002
      <<: *shared-env

  store3:
    image: dingodatabase/dingo-store:latest
    hostname: store3
    container_name: store3
    network_mode: host
    depends_on:
      - coordinator1
      - coordinator2
      - coordinator3
    environment:
      FLAGS_role: store
      RAFT_START_PORT: 20103
      SERVER_START_PORT: 20003
      INSTANCE_START_ID: 1003
      <<: *shared-env

  index1:
    image: dingodatabase/dingo-store:latest
    hostname: index1
    container_name: index1
    network_mode: host
    depends_on:
      - coordinator1
      - coordinator2
      - coordinator3
    environment:
      FLAGS_role: index
      INDEX_RAFT_START_PORT: 21101
      INDEX_SERVER_START_PORT: 21001
      INDEX_INSTANCE_START_ID: 1101
      <<: *shared-env
  index2:
    image: dingodatabase/dingo-store:latest
    hostname: index2
    container_name: index2
    network_mode: host
    depends_on:
      - coordinator1
      - coordinator2
      - coordinator3
    environment:
      FLAGS_role: index
      INDEX_RAFT_START_PORT: 21102
      INDEX_SERVER_START_PORT: 21002
      INDEX_INSTANCE_START_ID: 1102
      <<: *shared-env

  index3:
    image: dingodatabase/dingo-store:latest
    hostname: index3
    container_name: index3
    network_mode: host
    depends_on:
      - coordinator1
      - coordinator2
      - coordinator3
    environment:
      FLAGS_role: index
      INDEX_RAFT_START_PORT: 21103
      INDEX_SERVER_START_PORT: 21003
      INDEX_INSTANCE_START_ID: 1103
      <<: *shared-env

  executor:
    image: dingodatabase/dingo:latest
    hostname: executor
    container_name: executor
    ports:
      - 8765:8765
      - 3307:3307
    networks:
      - dingo_net
    environment:
       DINGO_ROLE: executor
       DINGO_HOSTNAME: executor
       DINGO_COORDINATORS: ${DINGO_HOST_IP}:22001,${DINGO_HOST_IP}:22002,${DINGO_HOST_IP}:22003
       DINGO_MYSQL_COORDINATORS: ${DINGO_HOST_IP}:22001

  proxy:
    image: dingodatabase/dingo:latest
    hostname: proxy
    container_name: proxy
    ports:
      - 13000:13000
      - 9999:9999
    networks:
      - dingo_net
    environment:
      DINGO_ROLE: proxy
      DINGO_HOSTNAME: proxy
      DINGODB_INIT_COUNT: 6
      DINGO_COORDINATORS: ${DINGO_HOST_IP}:22001,${DINGO_HOST_IP}:22002,${DINGO_HOST_IP}:22003

networks:
    dingo_net:
        driver: bridge
