Skip to content

Commit 83418f3

Browse files
Merge pull request #445 from Gauravpadam/20233110_docker_compose_refining
Docker compose refining
2 parents 52d2fb0 + 4af0b36 commit 83418f3

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,6 @@ dist
131131

132132
# ingore genrated APIdocs
133133
apidoc
134+
135+
# data generated by mongo replicas
134136
data/

docker-compose.yaml

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
version: '3'
2-
services:
3-
primary:
4-
image: mongo
5-
container_name: mongodb-primary
6-
ports:
7-
- "27017:27017"
8-
environment:
9-
MONGO_INITDB_REPLICA_SET: ReplicaSet
1+
version: "3.8"
102

11-
secondary1:
12-
image: mongo
13-
container_name: mongodb-secondary1
3+
services:
4+
mongo1:
5+
image: mongo:5
6+
container_name: mongo1
7+
command: ["--replSet", "my-replica-set", "--bind_ip_all", "--port", "30001"]
8+
volumes:
9+
- ./data/mongo-1:/data/db
1410
ports:
15-
- "27018:27017"
16-
environment:
17-
MONGO_INITDB_REPLICA_SET: ReplicaSet
11+
- 30001:30001
12+
healthcheck:
13+
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
14+
interval: 10s
15+
start_period: 30s
1816

19-
secondary2:
20-
image: mongo
21-
container_name: mongodb-secondary2
17+
mongo2:
18+
image: mongo:5
19+
container_name: mongo2
20+
command: ["--replSet", "my-replica-set", "--bind_ip_all", "--port", "30002"]
21+
volumes:
22+
- ./data/mongo-2:/data/db
2223
ports:
23-
- "27019:27017"
24-
environment:
25-
MONGO_INITDB_REPLICA_SET: ReplicaSet
24+
- 30002:30002
2625

27-
arbiter:
28-
image: mongo
29-
container_name: mongodb-arbiter
26+
mongo3:
27+
image: mongo:5
28+
container_name: mongo3
29+
command: ["--replSet", "my-replica-set", "--bind_ip_all", "--port", "30003"]
30+
volumes:
31+
- ./data/mongo-3:/data/db
3032
ports:
31-
- "27020:27017"
32-
environment:
33-
MONGO_INITDB_REPLICA_SET: ReplicaSet
34-
MONGO_INITDB_ARBITER: "yes"
33+
- 30003:30003

0 commit comments

Comments
 (0)