add healthcheck to mongodb to init replicaset if not already init
This commit is contained in:
1 parent
db20b4c1ff
commit
36f528fbf9
3 files changed
+17
-4
No files matched your search
@@ -52,6 +52,13 @@ services:
|
||||
- "27017:27017"
|
||||
volumes:
|
||||
- ./mongo/data:/data/db
|
||||
- ./mongo/init/init.js:/docker-entrypoint-initdb.d/init.js
|
||||
# - ./mongo/init/init.js:/docker-entrypoint-initdb.d/init.js // No longer needed
|
||||
env_file:
|
||||
- mongo.env
|
||||
healthcheck:
|
||||
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'mongodb:27017'}]}) }" | mongosh --port 27017 --quiet
|
||||
interval: 5s
|
||||
timeout: 30s
|
||||
start_period: 0s
|
||||
start_interval: 1s
|
||||
retries: 30
|
||||
Reference in new issue
Block a user