Skip to content

Commit

Permalink
Merge pull request #445 from Gauravpadam/20233110_docker_compose_refi…
Browse files Browse the repository at this point in the history
…ning

Docker compose refining
  • Loading branch information
TejasNair9977 authored Nov 8, 2023
2 parents 52d2fb0 + 4af0b36 commit 83418f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,6 @@ dist

# ingore genrated APIdocs
apidoc

# data generated by mongo replicas
data/
55 changes: 27 additions & 28 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
version: '3'
services:
primary:
image: mongo
container_name: mongodb-primary
ports:
- "27017:27017"
environment:
MONGO_INITDB_REPLICA_SET: ReplicaSet
version: "3.8"

secondary1:
image: mongo
container_name: mongodb-secondary1
services:
mongo1:
image: mongo:5
container_name: mongo1
command: ["--replSet", "my-replica-set", "--bind_ip_all", "--port", "30001"]
volumes:
- ./data/mongo-1:/data/db
ports:
- "27018:27017"
environment:
MONGO_INITDB_REPLICA_SET: ReplicaSet
- 30001:30001
healthcheck:
test: test $$(echo "rs.initiate({_id:'my-replica-set',members:[{_id:0,host:\"mongo1:30001\"},{_id:1,host:\"mongo2:30002\"},{_id:2,host:\"mongo3:30003\"}]}).ok || rs.status().ok" | mongo --port 30001 --quiet) -eq 1
interval: 10s
start_period: 30s

secondary2:
image: mongo
container_name: mongodb-secondary2
mongo2:
image: mongo:5
container_name: mongo2
command: ["--replSet", "my-replica-set", "--bind_ip_all", "--port", "30002"]
volumes:
- ./data/mongo-2:/data/db
ports:
- "27019:27017"
environment:
MONGO_INITDB_REPLICA_SET: ReplicaSet
- 30002:30002

arbiter:
image: mongo
container_name: mongodb-arbiter
mongo3:
image: mongo:5
container_name: mongo3
command: ["--replSet", "my-replica-set", "--bind_ip_all", "--port", "30003"]
volumes:
- ./data/mongo-3:/data/db
ports:
- "27020:27017"
environment:
MONGO_INITDB_REPLICA_SET: ReplicaSet
MONGO_INITDB_ARBITER: "yes"
- 30003:30003

0 comments on commit 83418f3

Please sign in to comment.