# Copyright Broadcom, Inc. All Rights Reserved.
# SPDX-License-Identifier: APACHE-2.0

services:
  mongodb-sharded:
    image: docker.io/bitnami/mongodb-sharded:8.2
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded
      - MONGODB_SHARDING_MODE=mongos
      - MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
      - MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_ROOT_PASSWORD=password123
    ports:
      - "27017:27017"

  mongodb-sharded-2:
    image: docker.io/bitnami/mongodb-sharded:8.2
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded-2
      - MONGODB_SHARDING_MODE=mongos
      - MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
      - MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_ROOT_PASSWORD=password123

  mongodb-shard0-primary:
    image: docker.io/bitnami/mongodb-sharded:8.2
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-primary
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-sharded
      - MONGODB_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_REPLICA_SET_NAME=shard0
    volumes:
      - 'shard0_data:/bitnami'

  mongodb-shard0-secondary:
    image: docker.io/bitnami/mongodb-sharded:8.2
    depends_on:
      - mongodb-shard0-primary
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-secondary
      - MONGODB_REPLICA_SET_MODE=secondary
      - MONGODB_PRIMARY_HOST=mongodb-shard0-primary
      - MONGODB_PRIMARY_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_REPLICA_SET_NAME=shard0
    volumes:
      - 'shard0_sec_data:/bitnami'

  mongodb-shard1-primary:
    image: docker.io/bitnami/mongodb-sharded:8.2
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-primary
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-sharded
      - MONGODB_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_REPLICA_SET_NAME=shard1
    volumes:
      - 'shard1_data:/bitnami'

  mongodb-shard1-secondary:
    image: docker.io/bitnami/mongodb-sharded:8.2
    depends_on:
      - mongodb-shard1-primary
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-secondary
      - MONGODB_REPLICA_SET_MODE=secondary
      - MONGODB_PRIMARY_HOST=mongodb-shard1-primary
      - MONGODB_PRIMARY_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_REPLICA_SET_NAME=shard1
    volumes:
      - 'shard1_sec_data:/bitnami'

  mongodb-shard2-primary:
    image: docker.io/bitnami/mongodb-sharded:8.2
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard2-primary
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-sharded
      - MONGODB_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_REPLICA_SET_NAME=shard2
    volumes:
      - 'shard2_data:/bitnami'

  mongodb-shard2-secondary:
    image: docker.io/bitnami/mongodb-sharded:8.2
    depends_on:
      - mongodb-shard2-primary
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard2-secondary
      - MONGODB_REPLICA_SET_MODE=secondary
      - MONGODB_PRIMARY_HOST=mongodb-shard2-primary
      - MONGODB_PRIMARY_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_REPLICA_SET_NAME=shard2
    volumes:
      - 'shard2_sec_data:/bitnami'

  mongodb-cfg-primary:
    image: docker.io/bitnami/mongodb-sharded:8.2
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg-primary
      - MONGODB_SHARDING_MODE=configsvr
      - MONGODB_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_REPLICA_SET_NAME=cfgreplicaset
    volumes:
      - 'cfg_data:/bitnami'

  mongodb-cfg-secondary:
    image: docker.io/bitnami/mongodb-sharded:8.2
    depends_on:
      - mongodb-cfg-primary
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg-secondary
      - MONGODB_REPLICA_SET_MODE=secondary
      - MONGODB_PRIMARY_HOST=mongodb-cfg-primary
      - MONGODB_PRIMARY_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_REPLICA_SET_NAME=cfgreplicaset
      - MONGODB_SHARDING_MODE=configsvr
    volumes:
      - 'cfg_sec_data:/bitnami'

volumes:
  shard0_data:
    driver: local
  shard0_sec_data:
    driver: local
  shard1_data:
    driver: local
  shard1_sec_data:
    driver: local
  shard2_data:
    driver: local
  shard2_sec_data:
    driver: local
  cfg_data:
    driver: local
  cfg_sec_data:
    driver: local
