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.
| Service | systemd unit | Listens on |
|---|---|---|
| Platform API | ngamia-platform | 127.0.0.1:4710 |
| KIDA identity | ngamia-kida | 127.0.0.1:4711 |
| NAK agent runtime | ngamia-nak | 127.0.0.1:4712 |
| UBONGO knowledge | ngamia-ubongo | 127.0.0.1:4713 |
| UBONGO parser | ngamia-ubongo-parser | 127.0.0.1:4714 |
ClamAV (apt install clamav-daemon) | clamav-daemon | 127.0.0.1:3310 |
MongoDB 8.3 (replica set rs0, TLS) | mongod | 127.0.0.1:27017 |
MongoDB Search (mongot 1.79) | mongot | localhost: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 -fLayout
| Path | Contents |
|---|---|
~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/current | symlink 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/*.env | service 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 host | databases 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-daemonSet 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 modelhost-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.shIt 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 URIngamia-ubongo starts only once this file exists.
Release
deploy/systemd/release.sh releaseThe script:
- builds the six binaries on your machine (glibc 2.39 or older);
- uploads them as a new release;
- switches
currentand restartsngamia-agent.target(each service runs its migrations inExecStartPre); - checks health. If the check fails, it rolls back to the previous release by itself.
Publish the docs
deploy/vps/deploy.sh docsdeploy/systemd/release.sh rollback switches to the previous release, and
release.sh status shows the services and readiness.