Custom MongoDB installation

Instructions for installing MongoDB instead of running it in docker

This page contains instruction on making a manual installation of MongoDB, instead of running MongoDB in Docker as is described here. In most cases we recommend running MongoDB in Docker, as it is easier to set up and manage.

Custom installation of MongoDB

Install the database software, MongoDB.

sudo apt-get install gnupg
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
   --dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org

Create a /etc/mongod.conf that contains the following:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
#  engine:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0


# how the process runs
processManagement:
  timeZoneInfo: /usr/share/zoneinfo

security:
  authorization: enabled

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

Then start the database

sudo systemctl enable mongod
sudo systemctl start mongod

Create the file ~/mongosh-admin.js containing (replace <ADMIN_PASSWORD>):

use admin
db.createUser(
  {
    user: "admin",
    pwd: "<ADMIN_PASSWORD>",
    roles: [
      { role: "userAdminAnyDatabase", db: "admin" },
      { role: "readWriteAnyDatabase", db: "admin" }
    ]
  }
)

Create the admin user

mongosh localhost < ~/mongosh-admin.js

Create the file ~/mongosh-api.js for the API user (replace <API_PASSWORD>):

productionsDb = db.getSiblingDB('agile-live-gui');

productionsDb.createUser({
  user: 'api',
  pwd: '<API_PASSWORD>',
  roles: [{ role: 'readWrite', db: 'agile-live-gui' }]
});

Create the API user

mongosh -u admin -p <ADMIN_PASSWORD> < ~/mongosh-api.js