Self-hosting

Self-hosting

What every Niles install needs, the two ways to run it, the first sign-in, the database and backups, upgrades, the ports and HTTPS.

Niles is one container and a Postgres database, run on a machine in your house. There are two ways to run it:

  • Docker Compose on one Linux machine. Most households want this one.
  • Kubernetes, with the Kustomize manifests in the repository, if you already run a cluster.

This page covers what both have in common.

What every install needs

  • A Linux machine or nodes with x86-64 CPUs. The image, ghcr.io/marknygaard/niles, is public and built for linux/amd64 only. No GPU is needed.
  • Postgres. Compose runs one beside Niles. On Kubernetes you bring your own. Niles needs no extensions and creates its own tables.
  • An MQTT broker and Zigbee2MQTT. Niles reaches every Zigbee device through them. See Satellites and hardware for the rest of what a house needs.
  • An ElevenLabs API key for hearing and a Cerebras API key for thinking.
  • Piper's HTTP server, to speak the replies.

Before its first start, Niles needs these from the environment:

VariableWhat it is
NILES_DATABASE_URLThe Postgres connection string, such as postgres://niles:password@db:5432/niles.
NILES_SECRET_KEY32 random bytes, base64 (openssl rand -base64 32). It seals every key typed into the app.
NILES_MQTT_USERNAME, NILES_MQTT_PASSWORDThe broker's login. The broker's address goes in niles.toml.
ELEVENLABS_API_KEY, CEREBRAS_API_KEYHearing and thinking.

Niles connects to the broker and builds its hearing and thinking clients before the app is up, which is why those four come from the environment. Every other setting and key is typed into the app and kept in Postgres.

The ports

PortDirectionFor
8080Into NilesThe app, the API and /healthz
10300Into NilesThe satellites, which stream what they hear to it
10301From Niles to each satelliteRinging timers and speaking announcements

Niles knows which room a satellite is in by the IP address it connects from, so the connection must reach Niles with that address intact. The Compose and Kubernetes pages say how. Each satellite's firmware is given the IP address of the machine or Service that answers on 10300.

The first sign-in

A new Niles has signing in off, and the app is open to anyone who can reach it. Open it from the house network, at http://<the machine's address>:8080, and switch signing in on:

  1. Make a GitHub OAuth app on github.com under Settings → Developer settings → OAuth Apps, with the callback URL https://<your niles host>/auth/github/callback.
  2. Put its client ID and secret in the Signing in card under Settings → People.
  3. Add the email address GitHub has verified for you to the list under it, then press Sign in with GitHub.

Signing in is on from then. Add the rest of the household the same way. People and voices and Security and privacy have the details.

Then work through Settings → Voice & AI, whose checklist says what is still missing, and add each satellite under Settings → Satellites.

The database and backups

Everything Niles keeps is in Postgres: settings, stored keys, rules, conversations, Saved items, voice prints and timers. Nothing else needs backing up. Dump it with pg_dump:

pg_dump -U niles niles > niles-backup.sql

The Docker Compose page has the commands for its database container.

Keep NILES_SECRET_KEY with the backups. A restored database is readable without it, but each key typed into the app has to be typed in again.

Upgrading

Settings → About Niles shows which Niles runs: its version, the commit it was built from, and when. It then says Up to date, or Update available with the date of the newest image and what changed since yours, newest first. Each change links to its pull request. While an update is available, Settings has a dot.

Niles checks two minutes after it starts, every six hours after that, and whenever About Niles opens. It asks GitHub, without signing in, for the latest image of ghcr.io/marknygaard/niles and for the commits between that image and the running one. The requests name the image and the running commit, and nothing about your house. Without a network the page says it couldn't check. A Niles built any other way, such as with cargo run, is a development build and doesn't check.

The page shows how to update where Niles runs:

  • Kubernetes on latest with imagePullPolicy: Always, as the shipped manifests run it: Restart now starts the newest image, and so does kubectl rollout restart deployment/niles.
  • A pinned tag: change it to the newest version, or pin the digest the page shows, then apply.
  • Docker Compose: docker compose pull niles, then docker compose up -d niles.

An app left open, the one on an iPhone's Home Screen included, reloads itself once when Niles comes back as another build.

An upgrade is a new image tag. The tags are latest (the newest release), each version (such as 0.4.0) and sha-<commit>. Pin a version to choose when you upgrade. Niles creates the tables it needs by itself, so there is no migration step. The releases and what changed in each are on GitHub.

Restarting

Some settings are read only when Niles starts: the broker, the language model, the satellites and a few more. While one of them waits for a restart, Settings says so at the top — "Some changes take effect after a restart: Zigbee & MQTT." — and the Settings menu entry has a dot. Changing the setting back clears both.

Restart now asks first. It says what a restart cuts short (a background job, approvals waiting, a wake-up ramp under way), then Niles stops in order, whatever runs it starts it again, and it is back in about half a minute. Anyone who can sign in can restart Niles; it cannot be done by voice.

The button appears only where something starts Niles again:

  • Kubernetes: always. The container restarts in the same pod, with no extra permissions. With imagePullPolicy: Always on the latest tag it also starts the newest image.
  • Docker Compose: the shipped compose.yaml sets NILES_SUPERVISOR: docker beside restart: unless-stopped.
  • Anything else: set NILES_SUPERVISOR to its name once it restarts Niles after a clean exit. For systemd that means Restart=always; Restart=on-failure and Docker's on-failure don't restart a clean exit.

Without one, Settings still says what waits; restart Niles where it runs.

Without a database the changes are lost at a restart, so there is no button; put the setting in niles.toml.

If Niles isn't back after two minutes the app says so. Look at the log: kubectl logs deploy/niles or docker compose logs niles.

Niles stops in the same order when Kubernetes or Docker stops it.

HTTPS for phones

Browsers send notifications only to a page served over HTTPS, so phone notifications and the app on an iPhone's Home Screen need Niles behind HTTPS. Put a reverse proxy with a certificate in front of port 8080, such as Caddy, Traefik, nginx or a tunnel, and have it send X-Forwarded-Proto: https. Niles then marks its session cookie secure.

Niles does not need to be reachable from the internet for any of this. Notifications reach phones through Apple's, Google's or Mozilla's push service. If you do expose it, expose only 8080 and keep 10300 on the house network, because satellites don't sign in. See If Niles can be reached from the internet.