From 43799c3a60c1633315bfcb7c00da3b4b714df7d9 Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Wed, 7 Aug 2024 01:31:07 +0300 Subject: [PATCH] build: add db credentials to docker --- .env.local.example | 6 +++++- gen/services/venom-db.service | 2 ++ scaffold.config.js | 2 ++ src/core/megahal.ts | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.env.local.example b/.env.local.example index effe74e..dcdb1d5 100644 --- a/.env.local.example +++ b/.env.local.example @@ -11,7 +11,7 @@ export DISCORD_APP_ID= export DISCORD_PUBLIC_KEY= export DISCORD_TOKEN= -# mongodb URI, e.g. "mongodb://localhost:27017" +# mongodb URI, e.g. "mongodb://localhost:27017" or "mongodb://:@:" export MONGODB_URI=mongodb://localhost:27017 ################################################################################# @@ -23,5 +23,9 @@ export APP_ROOT= # where the DB data is saved - absolute path, or relative to APP_ROOT export DB_PATH=data +# mongo db credentials for docker setup +export DB_USER= +export DB_PASS= + # logging export LOG_LEVEL=debug diff --git a/gen/services/venom-db.service b/gen/services/venom-db.service index 47f49d6..c3c1ce1 100644 --- a/gen/services/venom-db.service +++ b/gen/services/venom-db.service @@ -9,6 +9,8 @@ WorkingDirectory={{appRoot}} ExecStart=/usr/bin/docker run --name venom-db \ --volume {{dbPath}}/db:/data/db \ --volume {{dbPath}}/configdb:/data/configdb \ + -e MONGO_INITDB_ROOT_USERNAME={{dbUser}} \ + -e MONGO_INITDB_ROOT_PASSWORD={{dbPass}} \ -p 27017:27017 \ mongo:latest diff --git a/scaffold.config.js b/scaffold.config.js index 2384773..5c35907 100644 --- a/scaffold.config.js +++ b/scaffold.config.js @@ -21,6 +21,8 @@ module.exports = { data: { appRoot: process.env.APP_ROOT, dbPath: path.resolve(process.env.APP_ROOT ?? process.cwd(), process.env.DB_PATH), + dbUser: process.env.DB_USER, + dbPass: process.env.DB_PASS, }, name: '-', }, diff --git a/src/core/megahal.ts b/src/core/megahal.ts index e34d983..2b767cf 100644 --- a/src/core/megahal.ts +++ b/src/core/megahal.ts @@ -83,6 +83,8 @@ export async function trainMegahal(message: Discord.Message, replyChance: number totalMsgCount = 0 } + logger.debug('Total unsaved messages:', totalMsgCount) + const response = megahal.reply(input) if (Math.random() < replyChance && !isMuted()) {