Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose refining #445

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading