Skip to Content
The Ngamia platform API is in preview. Endpoints may change before general availability.
Self-hostingShared VPS with systemd

Shared VPS with systemd

This is how api.ngamia.com and docs.ngamia.com run: on a shared Ubuntu 24.04 host whose nginx already serves other sites, with native systemd services and no Docker. The host keeps only release binaries, not toolchains or images.

Servicesystemd unitListens on
Platform APIngamia-platform127.0.0.1:4710
KIDA identityngamia-kida127.0.0.1:4711
NAK agent runtimengamia-nak127.0.0.1:4712
UBONGO knowledgengamia-ubongo127.0.0.1:4713
UBONGO parserngamia-ubongo-parser127.0.0.1:4714
ClamAV (apt install clamav-daemon)clamav-daemon127.0.0.1:3310
MongoDB 8.3 (replica set rs0, TLS)mongod127.0.0.1:27017
MongoDB Search (mongot 1.79)mongotlocalhost:27028 (gRPC, TLS), health 127.0.0.1:4716

All five Ngamia units belong to ngamia-agent.target:

sudo systemctl restart ngamia-agent.target systemctl list-units 'ngamia-*' journalctl -u ngamia-platform -f

Layout

PathContents
~camel/projects/ngamia-agent/the git checkout; everything below is in its git-ignored .deploy/
.deploy/releases/<version>/bin/ngamia-platform, kida-server, kida-admin, ngamia-runtime, ubongo, ubongo-parser
.deploy/currentsymlink to the active release (the 5 newest are kept)
.deploy/shared/models/UBONGO’s embedding model
.deploy/docs/docs.ngamia.com (static files served by nginx)
/etc/ngamia-agent/*.envservice configuration (root, 0600)
/etc/ngamia-agent/secrets/keys, tokens, database URLs (service user, 0400)
/etc/ngamia-agent/kida/KIDA’s public JWKS, callers, provider and audiences
PostgreSQL 16 on the hostdatabases ngamia_kida, ngamia_platform, ngamia_nak, one role each, TLS verify-full

nginx terminates TLS (certbot) and proxies api.ngamia.com to 4710, and /identity/.well-known/* to 4711. It returns 404 for /internal/* and KIDA’s caller API. docs.ngamia.com is static files in ~camel/projects/ngamia-agent/.deploy/docs.

Install ClamAV (first time)

sudo apt-get install -y clamav-daemon clamav-freshclam printf 'TCPSocket 3310\nTCPAddr 127.0.0.1\n' | sudo tee -a /etc/clamav/clamd.conf # UBONGO checks signature freshness with VERSION, which Ubuntu disables: sudo sed -i 's/^EnableVersionCommand false/EnableVersionCommand true/' /etc/clamav/clamd.conf sudo systemctl restart clamav-daemon

Set up the host (first time, safe to re-run)

From your machine, with SSH access through the alias camel:

deploy/systemd/release.sh setup # pushes the commit to the host checkout, runs host-setup.sh deploy/systemd/release.sh model # copies UBONGO's embedding model

host-setup.sh creates any missing secrets (it never overwrites existing ones), the PostgreSQL roles and databases, KIDA’s configuration, every service’s .env and the systemd units.

Connect knowledge

Self-hosted MongoDB (how api.ngamia.com runs). On the host, from the checkout:

sudo deploy/systemd/mongodb-setup.sh

It installs MongoDB Community 8.3 and mongot (MongoDB Search, which provides $vectorSearch and $search). Both run on loopback. MongoDB runs as a single-member replica set with keyfile authentication and TLS from a local CA. The script also creates a readWrite-only ubongo user and writes /etc/ngamia-agent/ubongo-mongo.env. It is safe to re-run.

Or MongoDB Atlas: put the Atlas URI in /etc/ngamia-agent/ubongo-mongo.env on the host (root, 0600):

read -rsp "Atlas URI: " URI; echo printf 'UBONGO_MONGO_URI=%s\n' "$URI" | ssh camel 'sudo install -m 0600 /dev/stdin /etc/ngamia-agent/ubongo-mongo.env' unset URI

ngamia-ubongo starts only once this file exists.

Release

deploy/systemd/release.sh release

The script:

  1. builds the six binaries on your machine (glibc 2.39 or older);
  2. uploads them as a new release;
  3. switches current and restarts ngamia-agent.target (each service runs its migrations in ExecStartPre);
  4. checks health. If the check fails, it rolls back to the previous release by itself.

Publish the docs

deploy/vps/deploy.sh docs

deploy/systemd/release.sh rollback switches to the previous release, and release.sh status shows the services and readiness.

Last updated on