-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
93 lines (87 loc) · 2.66 KB
/
docker-compose.yaml
File metadata and controls
93 lines (87 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Simple Docker Compose File to Run the Storefront Application
services:
# The container representing the Main Node.js Application
web_application:
build: ./
restart: unless-stopped
ports:
- "3000:3000"
depends_on:
database:
condition: service_healthy
environment:
- HOSTNAME=0.0.0.0
- PORT=3000
- IS_PRODUCTION=false
- MONGO_CONNECTION_STRING=mongodb://database:27017,dbreplset01:27017,dbreplset02:27017/?replicaSet=rs0
# One-off container used to tie together the main MongoDB instance with its corresponding replication sets (once all
# three services pass the health checks). This container is to be disregarded once the replication sets are tied
# together (hence the no-restart policy).
dbreplsetup:
image: "mongo:latest"
restart: no
depends_on:
database:
condition: service_healthy
dbreplset01:
condition: service_healthy
dbreplset02:
condition: service_healthy
entrypoint: >
mongosh database:27017/admin --quiet --eval
'
rs.initiate();
rs.add({ host: "dbreplset01:27017", priority: 0, votes: 0 });
rs.add({ host: "dbreplset02:27017", priority: 0, votes: 0 });
'
# The container representing the database for the application.
database:
image: "mongo:latest"
restart: unless-stopped
ports:
- "27017:27017"
command: mongod --replSet rs0 --bind_ip_all
healthcheck:
test: echo 'rs.status().ok' | mongosh localhost:27017/admin --quiet
interval: 5s
timeout: 5s
start_period: 5s
retries: 5
volumes:
- "db_main_data:/data/db"
- "db_main_config:/data/configdb"
# The container representing the first replication set.
dbreplset01:
image: "mongo:latest"
restart: unless-stopped
command: mongod --replSet rs0 --bind_ip_all
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/admin --quiet
interval: 5s
timeout: 5s
start_period: 5s
retries: 5
volumes:
- "db_repl01_data:/data/db"
- "db_repl01_config:/data/configdb"
# The container representing the second replication set.
dbreplset02:
image: "mongo:latest"
restart: unless-stopped
command: mongod --replSet rs0 --bind_ip_all
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/admin --quiet
interval: 5s
timeout: 5s
start_period: 5s
retries: 5
volumes:
- "db_repl02_data:/data/db"
- "db_repl02_config:/data/configdb"
volumes:
db_main_data:
db_main_config:
db_repl01_data:
db_repl01_config:
db_repl02_data:
db_repl02_config: