From 1cea2faf21ae0c2b4970d7f0fdc8ee7c4c936ae2 Mon Sep 17 00:00:00 2001 From: Brutus5000 Date: Mon, 16 Jan 2023 19:50:00 +0100 Subject: [PATCH] Update to MongoDB 6.x --- faf-extra.yml | 2 +- scripts/init-mongodb.sh | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/faf-extra.yml b/faf-extra.yml index 732a1433..761087e9 100644 --- a/faf-extra.yml +++ b/faf-extra.yml @@ -26,7 +26,7 @@ services: # NoSQL database specifically used for nodebb # mongodb: - image: mongo:4.2.17 + image: mongo:6.0.3-focal restart: unless-stopped networks: - faf-extra diff --git a/scripts/init-mongodb.sh b/scripts/init-mongodb.sh index abd65254..92ac1d33 100755 --- a/scripts/init-mongodb.sh +++ b/scripts/init-mongodb.sh @@ -3,6 +3,10 @@ # fail on errors set -e +. config/extra/mongodb/mongodb.env + +alias mongo-exec='docker-compose -f faf-extra.yml exec -T mongodb mongosh -u ${MONGO_INITDB_ROOT_USERNAME} -p "${MONGO_INITDB_ROOT_PASSWORD}" --quiet' + if [ ! -f faf-extra.yml ]; then echo "You are not inside faf-stack. The working directory must be the root of faf-stack." exit 1 @@ -16,7 +20,7 @@ log_process_id=$! echo "Waiting for mongodb" current_wait=0 -while ! docker-compose -f faf-extra.yml exec -T mongodb mongo --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' >/dev/null 2>&1 +while ! mongo-exec --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' >/dev/null 2>&1 do if [ ${current_wait} -ge ${MAX_WAIT} ]; then echo "Timeout on startup of mongodb" @@ -30,8 +34,7 @@ done kill ${log_process_id} echo "Create mongodb database and user for nodebb" -. config/extra/mongodb/mongodb.env -docker-compose -f faf-extra.yml exec -T mongodb mongo -u "${MONGO_INITDB_ROOT_USERNAME}" -p "${MONGO_INITDB_ROOT_PASSWORD}" <