version: '3.8'

services:
  mongo1:
    image: mongo:latest
    container_name: mongo1
    ports:
      - "27019:27017"
    networks:
      - mongo-cluster
    environment:
      MONGO_INITDB_ROOT_USERNAME: rootuser
      MONGO_INITDB_ROOT_PASSWORD: rootpass
    volumes:
      - ./data/mongo1:/data/db
    command: --replSet rs0 --bind_ip_all

  mongo2:
    image: mongo:latest
    container_name: mongo2
    ports:
      - "27020:27017"
    networks:
      - mongo-cluster
    environment:
      MONGO_INITDB_ROOT_USERNAME: rootuser
      MONGO_INITDB_ROOT_PASSWORD: rootpass
    volumes:
      - ./data/mongo2:/data/db
    command: --replSet rs0 --bind_ip_all

  mongo3:
    image: mongo:latest
    container_name: mongo3
    ports:
      - "27021:27017"
    networks:
      - mongo-cluster
    environment:
      MONGO_INITDB_ROOT_USERNAME: rootuser
      MONGO_INITDB_ROOT_PASSWORD: rootpass
    volumes:
      - ./data/mongo3:/data/db
    command: --replSet rs0 --bind_ip_all

networks:
  mongo-cluster:
    driver: bridge
