Skip to content

Commit 1df8d58

Browse files
authored
Enable Docker Replication Sets (HabitRPG#15298)
- Enable docker replication sets using command - Initialize replication set using heartbeat and then use replication set status as heartbeat. - Prevent client from starting until mongo is in a state stable for connections.
1 parent 0542008 commit 1df8d58

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

docker-compose.dev.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ services:
2222
dockerfile: ./Dockerfile-Dev
2323
command: ["npm", "start"]
2424
depends_on:
25-
- mongo
25+
mongo:
26+
condition: service_healthy
2627
environment:
2728
- NODE_DB_URI=mongodb://mongo/habitrpg
2829
networks:
@@ -33,7 +34,16 @@ services:
3334
- .:/usr/src/habitica
3435
- /usr/src/habitica/node_modules
3536
mongo:
36-
image: mongo:3.6
37+
image: mongo:5.0.23
38+
restart: unless-stopped
39+
command: ["--replSet", "rs", "--bind_ip_all", "--port", "27017"]
40+
healthcheck:
41+
test: echo "try { rs.status() } catch (err) { rs.initiate() }" | mongosh --port 27017 --quiet
42+
interval: 10s
43+
timeout: 30s
44+
start_period: 0s
45+
start_interval: 1s
46+
retries: 30
3747
networks:
3848
- habitica
3949
ports:

0 commit comments

Comments
 (0)