fix: MongoDB init

This commit is contained in:
Sun-ZhenXing
2025-10-23 18:11:46 +08:00
parent bd84484bcc
commit af55ba73c0
2 changed files with 9 additions and 3 deletions

View File

@@ -49,6 +49,7 @@ services:
mongo-init:
<<: *default
image: mongo:${MONGO_VERSION:-8.0.13}
restart: on-failure
depends_on:
mongo1:
condition: service_healthy
@@ -66,11 +67,13 @@ services:
- -c
- |
set -e
echo "Waiting for MongoDB node to be ready..."
echo "Waiting for MongoDB nodes to be ready..."
sleep 5
mongosh \
--host "mongodb://$${MONGO_INITDB_ROOT_USERNAME}:$${MONGO_INITDB_ROOT_PASSWORD}@$${MONGO_HOST}:$${MONGO_PORT_1}" \
--host "$${MONGO_HOST}:$${MONGO_PORT_1}" \
--username "$${MONGO_INITDB_ROOT_USERNAME}" \
--password "$${MONGO_INITDB_ROOT_PASSWORD}" \
--authenticationDatabase admin \
--eval "
const config = {

View File

@@ -58,6 +58,7 @@ services:
mongo-init:
<<: *default
image: mongo:${MONGO_VERSION:-8.0.13}
restart: on-failure
depends_on:
mongo1:
condition: service_healthy
@@ -85,7 +86,9 @@ services:
sleep 5
mongosh \
--host "mongodb://$${MONGO_INITDB_ROOT_USERNAME}:$${MONGO_INITDB_ROOT_PASSWORD}@$${MONGO_HOST}:$${MONGO_PORT_1}" \
--host "$${MONGO_HOST}:$${MONGO_PORT_1}" \
--username "$${MONGO_INITDB_ROOT_USERNAME}" \
--password "$${MONGO_INITDB_ROOT_PASSWORD}" \
--authenticationDatabase admin \
--eval "
const config = {