# Running the bridge on a DigitalOcean droplet **Status: run once, on 2026-11-21**, on the existing Hermes droplet rather than a new one. What was actually done, including where it differed from the steps below, is recorded in `docs/evidence/droplet/2026-11-21.md`. The steps below have been corrected to match. ## What runs where ``` phone (Even app) --HTTPS--> Caddy :443 --> bridge 127.0.0.1:8787 --> Hermes 127.0.0.1:8642 | built-in Whisper (in the bridge process) ``` The bridge listens on loopback only. Caddy is the only thing exposed, and it provides the certificate. Speech is transcribed inside the bridge, so recordings never leave the droplet. Hermes can run on the same droplet (shown above) or elsewhere; if elsewhere, `HERMES_BASE_URL` must be `https://`. ## Sizing Measured on the development desktop (Intel i7-13850HX), bridge with `whisper-base`, 8-bit weights: | Measurement | Value | |---|---| | Memory after loading the model | about 0.5 GB | | Memory after transcribing | about 0.8 GB | | 11 s of speech, process pinned to one core | about 1.7 s | | Same, `whisper-tiny` | about 1.2 s, about 0.6 GB | | Model download at deploy time (`fetch-model`) | 79 MB (`whisper-base`), 4 s on the desktop's connection | | Longest pause of the bridge's event loop while transcribing | 3 ms (the model runs in a worker thread) | Pinning to one core made no difference to speed, so extra cores will not help; a single droplet vCPU is the relevant unit. **A shared droplet vCPU is slower than that desktop core by an amount that has not been measured.** If it were three times slower, 11 s of speech would take about 5 s, well inside the 30 s deadline. Suggested starting point, to be confirmed by measuring on the droplet: **2 GB RAM, 1 to 2 vCPU** for the bridge alone. 1 GB is likely too tight alongside the OS. If Hermes shares the droplet, add whatever Hermes needs; that was not measured. If transcription is too slow on the droplet, set `STT_MODEL=whisper-tiny` (faster, less accurate) and run `fetch-model` again. ## Steps 1. **Droplet and DNS.** Ubuntu LTS. Point a hostname at it (for example `bridge.example.com`). Firewall: allow 22, 80 and 443 only. 2. **Packages.** Node.js 22.13 or later, git, Caddy. 3. **User and directories.** ```sh useradd --system --home /opt/hermeven --shell /usr/sbin/nologin hermeven mkdir -p /opt/hermeven /etc/hermeven # The state directory is the service user's alone: mode 0700, set explicitly. install -d -m 0700 -o hermeven -g hermeven /var/lib/hermeven ``` The bridge also enforces this itself at every start. The directory that holds the database must be owned by the user the bridge runs as: if it belongs to anyone else (including root) the bridge refuses to start and leaves the directory exactly as it found it, even if its mode is already 0700. If the owner is right but the mode is looser, the bridge sets it to 0700. So `-o hermeven` in the command above matters as much as `-m 0700`. 4. **Code.** Put the repository at `/opt/hermeven/app` (a clone, or `git archive | tar -x`), then run `npm ci` there as the unprivileged `hermeven` user and hand the tree back to root afterwards (`chown -R root:root /opt/hermeven/app`), so package install scripts never run as root and the running service cannot modify its own code. (The dev dependencies are needed: the bridge runs through `tsx`.) Node.js is expected at `/opt/node/bin/node`. 5. **Configuration.** Copy `deploy/bridge.env.example` to `/etc/hermeven/bridge.env`, fill it in, `chmod 600`, `chown hermeven`. 5a. **Speech model.** As root (not the service user), fetch and verify the pinned model into a directory the service can read but not write: ```sh cd /opt/hermeven/app/services/bridge HERMEVEN_ENV_FILE=/etc/hermeven/bridge.env /opt/node/bin/node --import tsx src/cli.ts fetch-model HERMEVEN_ENV_FILE=/etc/hermeven/bridge.env /opt/node/bin/node --import tsx src/cli.ts verify-model ``` Every file is checked against the SHA-256 committed in `services/bridge/models/`. The running service never downloads anything: it re-verifies these files each time it loads the model and refuses to load if one is missing or different. This is the only step that needs outbound access to huggingface.co. 6. **Hermes.** Enable its API server with a key, bound to `127.0.0.1`. Use a read-only or test profile first. 7. **Service.** Copy `deploy/hermeven-bridge.service` to `/etc/systemd/system/`, then `systemctl daemon-reload && systemctl enable --now hermeven-bridge`. Watch `journalctl -u hermeven-bridge -f` for `stt.ready`. `stt.load_failed` with `reason: missing` or `mismatch` means step 5a was skipped or the files changed. 8. **TLS.** Put `deploy/Caddyfile.example` at `/etc/caddy/Caddyfile` with your hostname, reload Caddy, then check `curl https://bridge.example.com/healthz`. 9. **App build.** On your own machine: `HERMEVEN_BRIDGE_ORIGIN=https://bridge.example.com npm run -w @hermeven/even-client pack`. 10. **Pair.** On the droplet, as the service user with the same environment: ```sh cd /opt/hermeven/app/services/bridge runuser -u hermeven -- env HOME=/var/lib/hermeven HERMEVEN_ENV_FILE=/etc/hermeven/bridge.env \ /opt/node/bin/node --import tsx src/cli.ts pair ``` 11. **Origin.** Open the phone page, read Diagnostics, "Page origin", put it in `HERMEVEN_ALLOWED_ORIGINS`, restart the service. ## Things to check on the droplet and write down - Time from `stt.loading` to `stt.ready`, and memory of the service after a few questions. - `transcribe_ms` for a few real questions (the phone page shows it per question). - That `curl http://:8787/healthz` from outside **fails** (bridge not exposed). - `stat -c '%a' /var/lib/hermeven /var/lib/hermeven/hermeven.sqlite*` shows `700` and `600`. - That the unit's hardening options do not stop the model loading. `ProtectSystem=strict` and `MemoryMax` in particular are untested with ONNX Runtime. ## Not covered yet Backups of `/var/lib/hermeven`, log rotation, upgrades, monitoring, and a compiled build that would remove the need for dev dependencies on the droplet.