Skip to main content

MongoDB

MongoDB is IntelliAsk's primary datastore (users, conversations, messages). Its MONGO_* keys in config/.env, the auth bootstrap, storage, backup basics, and links to the official MongoDB docs.

MongoDB is IntelliAsk's primary datastore — users, conversations, messages, agents, and prompts all live here. The main app connects with MONGO_URI, and the Prometheus Exporter reads the same database to produce usage metrics.

Overview

Compose fileconfig/mongodb.compose.yml
Service namemongodb
Image variableMONGO_IMAGE (e.g. mongo:8.0.17)
Exposedinternal only — never publish Mongo
Databind-mounted at ${STORAGE_ROOT}/mongodb → /data/db

Environment variables

MongoDB's settings use the MONGO_ prefix in config/.env:

VariableDefaultWhat it does
MONGO_IMAGEmongo:8.0.17Image + tag to run.
MONGO_CPUS1.0CPU ceiling.
MONGO_MEMORY512mMemory ceiling.
MONGO_ROOT_USERNAMEintelliaskRoot user, bootstrapped on first start.
MONGO_ROOT_PASSWORD(secret)Root password — generated on first provision.
MONGO_URImongodb://…@mongodb:27017/IntelliAsk?authSource=adminConnection string the app uses.

Auth bootstrap happens once

MONGO_ROOT_USERNAME / MONGO_ROOT_PASSWORD are applied only on the first start with an empty data volume (MONGO_INITDB_ROOT_*). Changing them later does not re-create the user — you'd have to rotate it inside Mongo or wipe the volume. Never expose Mongo outside the Compose network.

After editing any MONGO_* value, apply with:

intelliask up mongodb

Storage & backup

Data is bind-mounted on the host at ${STORAGE_ROOT}/mongodb, so it survives container recreation. The simplest way to back up is the stack-wide command, which dumps MongoDB (and Postgres) plus the config in one step:

intelliask backup                 # DBs + config -> <storage>/backups/<timestamp>/

See Backup & restore for rotation and scheduling. To dump MongoDB on its own, use mongodump against the container:

docker compose exec mongodb \
  mongodump --username "$MONGO_ROOT_USERNAME" --password "$MONGO_ROOT_PASSWORD" \
  --authenticationDatabase admin --db IntelliAsk --archive=/data/db/intelliask.dump

Restore with the matching mongorestore --archive=…. For point-in-time or scheduled backups, see the official guide below.

Resource limits

The defaults (MONGO_CPUS=1.0, MONGO_MEMORY=512m) suit a small instance. Mongo's WiredTiger cache grows with available RAM — raise MONGO_MEMORY on busy or large deployments and keep an eye on docker stats.

Updating MongoDB

# 1. Bump the tag in config/.env, e.g. MONGO_IMAGE=mongo:8.0.18
# 2. Pull + recreate only Mongo
intelliask update mongodb

Mind major-version upgrades

Stay on a supported upgrade path — don't jump multiple major versions at once. Review the upstream release notes and back up first. The on-disk format is forward-compatible within a major series but not across big jumps.

Official documentation

Last updated on