version: '3.8'

services:

  mongo1:
    image: mongo
    restart: always
    ports:
      - 27017:27017
    volumes:
      - mongo1:/data/db
    entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0"]

  mongo2:
    image: mongo
    restart: always
    ports:
      - 27018:27017
    volumes:
      - mongo2:/data/db
    entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]

  mongo3:
    image: mongo
    restart: always
    ports:
      - 27019:27017
    volumes:
      - mongo3:/data/db
    entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]

  mongosetup:
    image: mongo
    links:
      - mongo1
    depends_on:
      - mongo1
      - mongo2
      - mongo3
    volumes:
      - .:/scripts
    restart: "no"
    entrypoint: [ "bash", "/scripts/mongo_setup.sh" ]

volumes:
  mongo1:
  mongo2:
  mongo3:
