Files
2026-12-01 06:21:47 +11:00

52 KiB
Raw Permalink Blame History

Doghouse

A self-hostable, Discord-style chat app: servers, text channels, DMs, voice and screen share. Runs as two Docker containers (the app and LiveKit) behind your existing Nginx Proxy Manager at https://doghouse.snoooopy.online.

What you get in the zip

doghouse-<version>/
  README.md                 this guide
  THIRD-PARTY-NOTICES.md    credits and licences (Nord and Solarized colour palettes)
  CHANGES-0.6.0.md          what changed in this release, upgrade steps
                            (CHANGES-0.5.0.md, CHANGES-0.4.1.md, CHANGES-0.4.0.md, CHANGES-0.3.1.md,
                            CHANGES-0.3.0.md, CHANGES-0.2.0.md, CHANGES-0.1.2.md,
                            CHANGES-0.1.1.md, CHANGES-M6.md: older releases)
  .gitignore                keeps deploy/.env and deploy/data/ out of git if you version the folder
  deploy/
    docker-compose.yml      project "doghouse": doghouse-app + doghouse-livekit
    Dockerfile              builds the app image (node 22 -> node:22-alpine, non-root)
    docker-entrypoint.sh    makes ./data writable, then runs the app as user "node"
    .env.example            settings template -> copy to .env
    livekit.yaml            LiveKit config (no secrets in it)
    npm-advanced.conf       paste into NPM's "Advanced" tab
    nginx-raw.conf          appendix: plain nginx instead of NPM
  apps/ packages/ ...       source code the image is built from

Deploy step by step

0. What you need

  • A Linux server with Docker Engine 24+ and the Compose plugin (docker compose version prints v2.x).
  • Nginx Proxy Manager already running in Docker on that server, with ports 80 and 443 reaching it from the internet.
  • The domain snoooopy.online in a DNS provider you can edit.
  • Access to your router (to forward the voice ports).
  • About 1 GB of disk for the images. The first build takes a few minutes.

1. DNS record

At your DNS provider add:

Type Name Value
A doghouse your public IPv4 address

(Or a CNAME doghouse -> your existing dynamic-DNS name.) If you use Cloudflare, set it to DNS only (grey cloud): voice traffic can't go through Cloudflare's proxy. Check it with nslookup doghouse.snoooopy.online.

2. Router port forwards (voice)

Web traffic (80/443) already goes to NPM. Voice and screen share need these extra forwards to the server's LAN IP:

Protocol Port(s) What
UDP 20000-20100 voice/screen-share media
TCP 7881 media fallback for networks that block UDP
UDP 3478 TURN (relays media for people behind strict firewalls)

Firewall note: Docker publishes these ports with its own iptables rules, which bypass ufw. ufw allow alone neither opens nor closes them; the router forwards are what matter. (If you also want ufw rules for documentation, sudo ufw allow 20000:20100/udp, sudo ufw allow 7881/tcp, sudo ufw allow 3478/udp are harmless.) Port 3000 (the app) and 7880 (LiveKit signalling) are never published; NPM reaches them over the Docker network.

3. Upload and unzip

scp doghouse-<version>.zip you@server:~
ssh you@server
unzip doghouse-<version>.zip
cd doghouse-<version>/deploy

Everything below runs in this deploy folder.

4. Settings (.env)

cp .env.example .env
docker run --rm livekit/livekit-server:v1.13.9 generate-keys

generate-keys prints an API Key and an API Secret. Put them into .env:

LIVEKIT_API_KEY=APIxxxxxxxxxxxx
LIVEKIT_API_SECRET=<the long secret, at least 32 characters>

Check the other values (they're already right for doghouse.snoooopy.online): APP_NAME, PUBLIC_URL=https://doghouse.snoooopy.online, LIVEKIT_PUBLIC_URL=wss://doghouse.snoooopy.online/livekit, NODE_ENV=production, TRUST_PROXY_HOPS=1, MAX_UPLOAD_MB=25, VIDEO_ENABLED=true (webcams; false turns them off). Keep .env private (chmod 600 .env).

Two more settings live in .env, so upgrades never overwrite them:

  • LIVEKIT_NODE_IP: your public IP (curl -4 ifconfig.me). Recommended: LiveKit then advertises it directly instead of looking it up via STUN at every start. Leave it empty to use STUN.
  • DOGHOUSE_NETWORK: the Docker network to join (step 5). Default doghouse_net.

5. Docker network, and connect NPM to it

The app, LiveKit and NPM talk over one shared network called doghouse_net:

docker network create doghouse_net
docker ps --format '{{.Names}}'            # find your NPM container's name
docker network connect doghouse_net <npm-container-name>

If NPM was started with its own compose file, add the network there instead so it survives NPM re-creates:

services:
  app:            # the NPM service
    networks: [default, doghouse_net]
networks:
  doghouse_net:
    external: true

then docker compose up -d in NPM's folder.

Already have a network NPM is on (e.g. homelab)? Skip the commands above and set DOGHOUSE_NETWORK=homelab in .env instead. Don't edit docker-compose.yml for this (an upgrade would overwrite it), and don't use network_mode:. network_mode: host or network_mode: homelab is wrong; joining a network is done with networks:, which the compose file already does. In host mode NPM can no longer reach doghouse-livekit:7880, LiveKit can't send webhooks to doghouse-app:3000, and DNS inside the container can break (see Troubleshooting). Check:

docker inspect doghouse-livekit --format '{{.HostConfig.NetworkMode}}'   # doghouse_net (or your DOGHOUSE_NETWORK), never "host"
docker exec doghouse-app cat /etc/resolv.conf                           # nameserver 127.0.0.11

Containers on a user-defined network use Docker's embedded DNS, nameserver 127.0.0.11.

6. Start Doghouse

docker compose up -d
docker compose ps                  # both "running"; doghouse-app becomes "healthy" within ~30 s
docker compose logs -f app         # Ctrl+C to stop following

The first run builds the app image (a few minutes). Since 0.6 the image is tagged with the version (doghouse-app:<version>), so a new release always builds its own image the first time and a plain up -d is enough; docker compose up -d --build still works and forces a rebuild (see Upgrades). ./data is created next to the compose file and holds the database and uploads.

7. Nginx Proxy Manager: proxy host

In NPM's web UI: Hosts > Proxy Hosts > Add Proxy Host.

Details tab

Field Value
Domain Names doghouse.snoooopy.online
Scheme http
Forward Hostname / IP doghouse-app
Forward Port 3000
Cache Assets off
Block Common Exploits on
Websockets Support on (chat uses a WebSocket at /ws)
Access List Publicly Accessible

SSL tab

Field Value
SSL Certificate Request a new SSL Certificate (Let's Encrypt)
Force SSL on
HTTP/2 Support on
HSTS Enabled on (leave HSTS Subdomains off)
Email / Agree to ToS your email, tick the box

Advanced tab: paste the whole content of deploy/npm-advanced.conf into Custom Nginx Configuration. It adds the LiveKit signalling route /livekit/ (forwarded to doghouse-livekit:7880 with the prefix stripped, WebSocket upgrade, 24 h timeouts) and the upload limit client_max_body_size 30m. If you change MAX_UPLOAD_MB, set client_max_body_size a few MB above it.

Save. The certificate request needs DNS (step 1) to point at you already.

About X-Forwarded-For: NPM appends the client address to any X-Forwarded-For header the client sent, and this can't be reliably changed from the Advanced tab. That's safe here: with TRUST_PROXY_HOPS=1 the app only trusts the last (rightmost) address, which NPM writes from the real connection, so a forged header can't change the IP used for rate limiting.

8. First run

  1. Open https://doghouse.snoooopy.online. The first account you register becomes the instance admin, so do it straight away.
  2. Close open sign-ups: User settings (gear, bottom left) > Registration, turn off Open registration. New people then need an invite (create one there, or use a server's invite link).
  3. Create a server; it comes with a text and a voice channel. Join the voice channel from two devices (one on mobile data) to check voice works. Turn a camera on to check video (or set VIDEO_ENABLED=false in .env if your upload is slow; see "Bandwidth" under Development).

Backups

Everything lives in deploy/data/ (SQLite database chat.db + uploads/) and deploy/.env.

cd ~/doghouse-<version>/deploy
docker compose stop app                       # consistent copy of the database
tar czf ~/doghouse-backup-$(date +%F-%H%M%S).tgz data .env
docker compose start app

Each backup gets the date and time in its name, so a second backup on the same day never replaces the first (QA-96). Keep the one from before an upgrade until you're happy with the new version. Restore: stop, put data/ and .env back, docker compose up -d. Voice has no state to back up. data/vapid.json holds the push notification key (see "Push notifications"); it is in the backup, and a restore keeps every device's notifications working. It is a secret: it is never in the release zip.

Search index

Message search (0.5) keeps its index in the database and updates it by itself; there is nothing to maintain. The index points at SQLite's internal row numbers, and some database tools can renumber those: a hand-run VACUUM, a .dump and restore, or .recover. A stale index is detected and rebuilt at start: every time Doghouse starts it checks that each indexed row is still the message it was (a few tens of milliseconds per 100,000 messages), and if not it rebuilds the index and logs one line, Search index was out of step with messages (...); rebuilt <n> messages in <ms> ms. So after any such tool, just restart Doghouse. You can also rebuild by hand at any time (safe while Doghouse runs; well under a second per 100,000 messages):

cd ~/doghouse-<version>/deploy
docker compose exec -u node app node apps/server/dist/scripts/rebuild-search.js

From the release zip or from source (npm start, see Development): from the folder you run it in, with the same DATA_DIR or DB_PATH as the server, run node apps/server/dist/scripts/rebuild-search.js. It prints Search index rebuilt: <n> messages in <ms> ms (<database path>). If it says No database at <path>, it was pointed at the wrong folder: it never creates a database, so check DATA_DIR or DB_PATH and run it again. While Doghouse is writing it waits its turn (up to 5 seconds) rather than failing.

Install as an app (PWA)

Doghouse can be installed to the home screen / desktop (Chrome, Edge, Android: Install in Settings → App and notifications, or the browser menu; iPhone/iPad: Safari Share → Add to Home Screen, and the same settings page shows the steps). It needs HTTPS (your NPM proxy host already provides it).

  • /manifest.webmanifest is built from APP_NAME (name, short name, icons); /sw.js is the service worker, served no-cache with the app version filled in. Both are served by the app, not files in dist.
  • The service worker caches no app files: only a small offline page (/offline.html) shown when the server can't be reached. An upgrade installs a new worker, which never takes over by itself: an open page asks it to, and the worker agrees only when that is the only open window and nobody is in a call or voice channel (a tab in a call holds the Web Lock doghouse-active-call). Otherwise it waits until the other tabs close or the call ends, so people never run a mix of old and new files and a call is never interrupted.
  • Icons are generated (node scripts/make-icons.mjs, from scripts/icons/*.svg) and committed in apps/web/public/icons/; rerun the script only if you change the artwork.
  • If your reverse proxy rewrites headers, don't add caching to /sw.js or /manifest.webmanifest.

Push notifications

Settings > App and notifications switches notifications on per device (the browser asks for permission only then). Notified: direct and group messages, @mentions and replies to you; per-server, per-channel and per-DM levels (all / mentions only / nothing), Do Not Disturb and quiet hours (in your own time zone). Nothing is sent for a conversation you are looking at in a focused tab. On iPhone it works only after "Add to Home Screen" (iOS 16.4+).

Privacy: the browser's own push service (Google, Apple or Mozilla) carries the message, encrypted for your browser, so they can't read it. They do see that a notification was sent and when. "Show message content in notifications" off means the push contains no message text at all.

Your server must reach the push services over HTTPS (fcm.googleapis.com, *.push.apple.com, updates.push.services.mozilla.com, *.notify.windows.com). Restricted egress or broken DNS looks like "pushes never arrive". Don't rotate the VAPID key unless you must (see VAPID_* below).

Each account can have up to 10 devices (the push queue and its limits: see "Calls ring" below); adding an 11th replaces the one that last received a push longest ago. A device whose push service rejects it five times within 24 hours (403, 401, 400, a redirect, and so on; a success resets the count, and timeouts, 408, 413, 429 and 5xx never count) is switched off and shown as "Not working" in Settings: switch notifications on again on that device. If the Google, Apple or Mozilla host you use isn't on the list above, add it with PUSH_ENDPOINT_ALLOW.

Calls ring, and ringtones

A DM or group call rings the other people: a card with Accept and Decline, a looping tone and (on phones) a vibration, and a push that rings a closed app (the ring push expires after 30 s; a call-end push clears it). The caller hears a soft ringback. There is no loud ring with Do Not Disturb, in quiet hours or while you are already in a call (the card still shows), and with two tabs open only the visible one rings aloud. Settings > App and notifications has three built-in tones, a volume slider, Preview, and "Use my own ringtone" (mp3, ogg Vorbis/Opus or wav, up to 1 MB and 30 s): the file is checked and kept in that browser only, never uploaded, and isn't in your backup. How long a call rings: CALL_RING_TIMEOUT_MS. Pushes use two queues so a slow message push never delays a ring (calls: 16 at a time, 4 s timeout; messages: 8 at a time, 10 s; an endpoint that timed out is skipped for message pushes for 60 s).

Upgrades

Going from 0.5.0 to 0.6.0? Back up first, then follow Upgrading 0.5.0 -> 0.6.0 below, with docker compose up -d --build. Its step 5 is the rollback to 0.5.0, which needs that backup. Going from 0.4.1 to 0.5.0? Follow Upgrading 0.4.1 -> 0.5.0 below. Its step 4 is the rollback to 0.4.1. Going from 0.4.0 to 0.4.1? It's a drop-in: see Upgrading 0.4.0 -> 0.4.1. Going from 0.3.1 to 0.4.0? Follow Upgrading 0.3.1 -> 0.4.0 below. Its step 4 is the rollback to 0.3.1. Still on 0.3.0? You can go straight to 0.4.0 with the same steps, reading doghouse-0.3.0 for doghouse-0.3.1 (0.4.0 includes 0.3.1's call fix), and roll back to 0.3.1, not 0.3.0 (see step 4). Each version's own steps are below, oldest first; these general steps apply to all of them:

  1. Back up (above).
  2. Unzip the new version next to the old one and copy your settings and data over:
    unzip doghouse-<new>.zip
    cp doghouse-<old>/deploy/.env doghouse-<new>/deploy/
    cd doghouse-<old>/deploy && docker compose down
    mv data ../../doghouse-<new>/deploy/
    cd ../../doghouse-<new>/deploy && docker compose up -d
    
    From 0.6.0 on, the app image is named doghouse-app:<version>, and Compose builds it when it isn't there yet, so up -d is enough and you can't start a new release on an old image by forgetting --build. (Releases up to 0.5.0 name it doghouse-app:local and need up -d --build; their steps below keep it.) up -d --build is still fine: it just rebuilds. The compose file also says pull_policy: never, so Compose builds a missing image instead of first trying to pull doghouse-app from Docker Hub. A development zip (one with a commit hash in its name, doghouse-<version>.<hash>.zip) tags its image doghouse-app:<version>-<hash>, so each test zip builds its own image on a plain up -d too.
  3. Database migrations run automatically on start. Check docker compose logs app.
  4. Compare .env.example with your .env for new settings, and re-paste npm-advanced.conf into NPM if the changes notes say it changed.

Data survives docker compose down / up because it's in ./data on the host.

Upgrading 0.1.0 -> 0.1.1

0.1.1 fixes one display bug (QA-8, see CHANGES-0.1.1.md). It has no database changes, no new .env settings, and docker-compose.yml, livekit.yaml and npm-advanced.conf are unchanged.

  1. Back up ./data (and .env), as in Backups.
  2. Keep your existing deploy/.env, and your deploy/livekit.yaml if you edited it.
  3. Replace the source files with the ones from doghouse-0.1.1.zip: either unzip it next to the old folder and move data/ and .env across as in the steps above, or unzip it over the old folder, taking care not to overwrite your .env (the zip has none) or an edited livekit.yaml.
  4. From deploy/, run docker compose up -d --build, then check docker compose ps shows both containers healthy.

Upgrading 0.1.1 -> 0.1.2

0.1.2 fixes the LiveKit startup crash loop ("could not resolve external IP"), moves voice media to UDP 20000-20100 (from 50000-50100, which could fail with "address already in use") and makes the Docker network configurable. It has no database changes; npm-advanced.conf is unchanged. docker-compose.yml and livekit.yaml changed: use the new ones, and if you had edited livekit.yaml, re-apply your edits to the new file (keep its port range).

  1. Back up ./data and .env (Backups). Keep your existing .env.
  2. Add the two new settings to your existing deploy/.env (see .env.example):
    LIVEKIT_NODE_IP=<your public IP, from: curl -4 ifconfig.me>
    DOGHOUSE_NETWORK=doghouse_net
    
    If you edited docker-compose.yml to use your own network (e.g. homelab), set DOGHOUSE_NETWORK=homelab instead and use the new compose file unedited. Remove any network_mode: line.
  3. Router and firewall: forward UDP 20000-20100 to the server and remove the old UDP 50000-50100 forward. Same for ufw if you added rules: sudo ufw allow 20000:20100/udp and sudo ufw delete allow 50000:50100/udp.
  4. Replace the source files from doghouse-0.1.2.zip, as for 0.1.1 above, then from deploy/: docker compose up -d --build. Check docker compose ps and docker compose logs livekit.

Upgrading 0.1.2 -> 0.2.0

0.2.0 adds profiles, server icons and banners, group DMs, and DM/group calls with webcams (see CHANGES-0.2.0.md). It changes the database (migrations 004-007, applied automatically on start), so a rollback needs the backup. docker-compose.yml, livekit.yaml, npm-advanced.conf and the router ports are unchanged.

  1. In doghouse-0.1.2/deploy: docker compose down, then back up data and .env (Backups).
  2. Unzip doghouse-0.2.0.zip into a fresh folder next to the old one (not over it). Copy deploy/.env across and move deploy/data across, as in the general steps above. If you had edited livekit.yaml, re-apply your edits to the new file.
  3. Add the new setting to deploy/.env: VIDEO_ENABLED=true (webcams; false turns them off if your upload is slow. About 5-10 Mbps of server upload for five people on camera). Optional, defaults are fine: CALL_RING_TIMEOUT_MS (30000) and MEDIA_DIR (data/media, inside ./data, so it's in your backup).
  4. From doghouse-0.2.0/deploy: docker compose up -d --build. Check docker compose ps (both healthy) and docker compose logs app (the app starts with no errors; the database changes are applied quietly on start).
  5. Rollback: stop 0.2.0, restore the backup into the 0.1.2 folder, and start 0.1.2. Never run 0.1.2 on the upgraded data.
  6. Go through the real-device checklist in CHANGES-0.2.0.md.

Upgrading 0.2.0 -> 0.3.0

0.3.0 adds installing Doghouse as an app, push notifications, and ringing calls with ringtones (see CHANGES-0.3.0.md). It changes the database (migration 008, additive, applied automatically on start), so a rollback needs the backup. No new ports; docker-compose.yml, livekit.yaml and npm-advanced.conf are unchanged.

  1. In doghouse-0.2.0/deploy: docker compose down, then back up data and .env (Backups). From this version data/vapid.json (the push key pair, made on first start) is part of the backup too.
  2. Unzip doghouse-0.3.0.zip into a fresh folder, copy deploy/.env across and move deploy/data across, as in the general steps above.
  3. Nothing new is required in .env. Optional: PUSH_ENDPOINT_ALLOW (extra push-service hosts; only if your browsers' push service isn't Google, Apple, Mozilla or Windows) and the VAPID_* pair if you want your own keys. Your server needs outbound HTTPS to the push services (see Push notifications).
  4. Your reverse proxy must not cache /sw.js or /manifest.webmanifest.
  5. From doghouse-0.3.0/deploy: docker compose up -d --build. Check docker compose ps: the app starts healthy (both containers healthy), and docker compose logs app shows no errors. Migration 008 is applied quietly on start; it doesn't print a log line.
  6. Rollback: stop 0.3.0, restore the backup into the 0.2.0 folder, and start 0.2.0. Never run 0.2.0 on the upgraded data. Custom ringtones live in each person's browser, not on the server.
  7. Go through the real-device checklist in CHANGES-0.3.0.md (real push, iPhone, ringing).
  8. Known issue in 0.3.0, fixed in 0.3.1: starting a call within a second or two of the previous one ending could, rarely, drop the new call at connect. Upgrade on to 0.3.1 (below).

Upgrading 0.3.0 -> 0.3.1

0.3.1 is a small fix release (see CHANGES-0.3.1.md). It has no database changes, no new settings and no new ports; docker-compose.yml, livekit.yaml and npm-advanced.conf are unchanged.

  1. In doghouse-0.3.0/deploy: docker compose down, then back up data and .env (Backups).
  2. Unzip doghouse-0.3.1.zip into a fresh folder, copy deploy/.env across and move deploy/data across, as in the general steps above.
  3. From doghouse-0.3.1/deploy: docker compose up -d --build. Check docker compose ps (both healthy) and docker compose logs app (no errors). Calls going on during the upgrade end, as with any restart. On its first start 0.3.1 closes the LiveKit call rooms left over from 0.3.0 (each call now gets its own room); nothing to do.
  4. Rollback: stop 0.3.1, move data back into the 0.3.0 folder and start 0.3.0. With no database changes, 0.3.0 runs on the same data.

Upgrading 0.3.1 -> 0.4.0

0.4.0 adds pinned messages, blocking and theme presets (see CHANGES-0.4.0.md). It changes the database (migration 009, additive, applied automatically on start). No new settings and no new ports; docker-compose.yml, livekit.yaml and npm-advanced.conf are unchanged.

On 0.3.0? Go straight to 0.4.0 with these steps, reading doghouse-0.3.0 for doghouse-0.3.1 (QA-99). 0.4.0 includes everything in 0.3.1 (its call fix and its start-up clean-up of old call rooms, see CHANGES-0.3.1.md), and 0.3.1 has no database or deploy changes of its own. For a rollback, see step 4: roll back to 0.3.1, not 0.3.0.

  1. In doghouse-0.3.1/deploy: docker compose down, then back up data and .env (Backups).

  2. Unzip doghouse-0.4.0.zip into a fresh folder, copy deploy/.env across and move deploy/data across, as in the general steps above.

  3. From doghouse-0.4.0/deploy: docker compose up -d --build. Check docker compose ps (both healthy) and docker compose logs app (no errors). Migration 009 is applied quietly on start; Settings and /api/health now show 0.4.0. Calls going on during the upgrade end, as with any restart.

  4. Rollback to 0.3.1, if you need it:

    1. In doghouse-0.4.0/deploy: docker compose down.
    2. Move data back into the 0.3.1 folder: mv data ../../doghouse-0.3.1/deploy/. That folder still has its .env. If you deleted it, unzip doghouse-0.3.1.zip into a fresh folder first and copy .env into its deploy folder from doghouse-0.4.0/deploy (QA-100). Coming from 0.3.0? Roll back to 0.3.1, not 0.3.0: you have no 0.3.1 folder, so unzip doghouse-0.3.1.zip into a fresh folder, copy .env from doghouse-0.4.0/deploy into its deploy folder, then do this step or step 3 there. 0.3.0 also runs on the data, but it still has the rare call drop that 0.3.1 fixed.
    3. Optional, instead of step 2: restore the backup you made before the upgrade. In doghouse-0.3.1/deploy: tar xzf ~/doghouse-backup-<date>.tgz (it puts back data and .env). This loses everything since the upgrade: messages, pins, blocks and theme changes. Only do this if the data itself is the problem. Then, still in doghouse-0.3.1/deploy, rename the old 0.4 data so it is never used by mistake: mv ../../doghouse-0.4.0/deploy/data ../../doghouse-0.4.0/deploy/data-before-rollback-$(date +%F-%H%M%S). The date and time in the name mean a second rollback never puts the newer data inside an older data-before-rollback folder (QA-98). A later upgrade then moves the restored data in as usual.
    4. In doghouse-0.3.1/deploy: docker compose up -d --build. 0.3.1 runs on the moved data (or the restored backup) and ignores the pins and blocks tables. Messages sent on 0.4.0 are kept, unless you restored the backup in step 3 (QA-97).

    While rolled back, blocking is off and the new themes show as Dark; CHANGES-0.4.0.md lists what changes and what comes back when you upgrade again.

  5. Go through the real-device checklist in CHANGES-0.4.0.md.

Upgrading 0.4.0 -> 0.4.1

0.4.1 is a small fix release (see CHANGES-0.4.1.md): a draft in a DM or group DM is no longer wiped when the other person sends. It is a drop-in: no database changes, no new settings and no new ports; docker-compose.yml, Dockerfile, livekit.yaml and npm-advanced.conf are unchanged.

  1. In doghouse-0.4.0/deploy: docker compose down, then back up data and .env (Backups).
  2. Unzip doghouse-0.4.1.zip into a fresh folder, copy deploy/.env across and move deploy/data across, as in the general steps above.
  3. From doghouse-0.4.1/deploy: docker compose up -d --build. Check docker compose ps (both healthy) and docker compose logs app (no errors). Settings and /api/health now show 0.4.1.
  4. Rollback: stop 0.4.1, move data back into the 0.4.0 folder and start 0.4.0. With no database changes, 0.4.0 runs on the same data.

Upgrading 0.4.1 -> 0.5.0

0.5.0 adds message search, custom server emoji and threads (see CHANGES-0.5.0.md). It changes the database (migration 010, additive, applied automatically on start). No new settings and no new ports; docker-compose.yml, livekit.yaml and npm-advanced.conf are unchanged.

On 0.4.0 or 0.3.x? You can go straight to 0.5.0 with these steps, reading your folder name for doghouse-0.4.1. 0.5.0 includes every earlier fix, and the migrations in between run on start, in order. For a rollback, see step 4: roll back to 0.4.1, not to an earlier version.

  1. In doghouse-0.4.1/deploy: docker compose down, then back up data and .env (Backups).

  2. Unzip doghouse-0.5.0.zip into a fresh folder, copy deploy/.env across and move deploy/data across, as in the general steps above.

  3. From doghouse-0.5.0/deploy: docker compose up -d --build. Check docker compose ps (both healthy) and docker compose logs app (no errors). Migration 010 runs on the first start: it builds the search index from your existing messages (about 0.5 s for 118,000 messages on a test machine) and the server is healthy about a second after start. The database grows by about a third (+37% on that 118,000-message set). Settings and /api/health now show 0.5.0. A start-up check then confirms the search index is in step (a few tens of milliseconds per 100,000 messages) and, if needed, moves custom emoji pictures into media/emoji and moves any thread-reply pins made under 0.4.1 into their thread. You can also rebuild the search index by hand (see Search index).

  4. Rollback to 0.4.1, if you need it:

    1. In doghouse-0.5.0/deploy: docker compose down.
    2. Move data back into the 0.4.1 folder: mv data ../../doghouse-0.4.1/deploy/. That folder still has its .env. If you deleted it, unzip doghouse-0.4.1.zip into a fresh folder first and copy .env into its deploy folder from doghouse-0.5.0/deploy.
    3. Optional, instead of step 2: restore the backup you made before the upgrade. In doghouse-0.4.1/deploy: tar xzf ~/doghouse-backup-<date>.tgz (it puts back data and .env). This loses everything since the upgrade: messages, custom emoji and threads. Only do this if the data itself is the problem. Then, still in doghouse-0.4.1/deploy, rename the old 0.5 data so it is never used by mistake: mv ../../doghouse-0.5.0/deploy/data ../../doghouse-0.5.0/deploy/data-before-rollback-$(date +%F-%H%M%S).
    4. In doghouse-0.4.1/deploy: docker compose up -d --build. 0.4.1 runs on the moved data (or the restored backup) and ignores the new 0.5 tables. Messages sent on 0.5.0 are kept, unless you restored the backup in step 3.

    While rolled back:

    • Custom emoji in messages show as raw <:name:...> text, and custom reactions show as a c:<id> pill that 0.4.1 can't remove. The pictures stay in media/emoji (0.4.1's clean-up doesn't touch them) and come back when you upgrade again.
    • Thread replies show inline in the channel as ordinary messages. Pins made inside a thread aren't listed, and the channel's unread count includes the replies. Upgrading again puts them back in their threads; a thread reply pinned under 0.4.1 moves to its thread at the next start, and nothing is unpinned.
  5. Go through the real-device checklist in CHANGES-0.5.0.md.

Tested: REQUIRE_LIVEKIT=1 npm run check is shared 49, server 690, web 1701, 0 failed. A full e2e run (REQUIRE_LIVEKIT=1 npm run e2e) is 114 passed, 100 skipped, 0 failed.

Upgrading 0.5.0 -> 0.6.0

0.6.0 adds custom roles and channel permissions (with private and read-only channels) and statuses (Online, Idle, Do not disturb, Invisible, custom text); see CHANGES-0.6.0.md. It changes the database (migration 011, additive, applied automatically on start) and fixes a security issue in 0.5.0 and earlier. No new settings and no new ports. The app image is now tagged with the version: deploy/docker-compose.yml uses doghouse-app:0.6.0 instead of doghouse-app:local.

Back up first. Migration 011 can't be undone, so the only safe way back to 0.5.0 is the backup you make in step 1.

On 0.4.x or 0.3.x? You can go straight to 0.6.0 with these steps, reading your folder name for doghouse-0.5.0; the migrations in between run on start, in order.

  1. In doghouse-0.5.0/deploy: docker compose down, then back up data and .env (Backups). Keep that .tgz until you're happy with 0.6.0.
  2. Unzip doghouse-0.6.0.zip next to the old folder (it unpacks into doghouse-0.6.0/), copy deploy/.env across and move deploy/data across, as in the general steps above.
  3. From doghouse-0.6.0/deploy: docker compose up -d --build. Use --build for this upgrade: it always builds the 0.6.0 image from the files you just unzipped (the first build takes a few minutes). A plain up -d would also build the missing doghouse-app:0.6.0 tag, but --build leaves no doubt. Check docker compose ps (both healthy) and docker compose logs app (no errors). Migration 011 runs on the first start and gives every server an @everyone role with exactly the 0.5.0 member rights, so nothing changes for anyone until you set up roles.
  4. Confirm the version: Settings > App and notifications > About shows 0.6.0 (build ...), and so does /api/health. docker images doghouse-app lists a 0.6.0 tag. If About still says 0.5.0, run step 3 again (with --build) in the 0.6.0 folder.
  5. Rollback to 0.5.0, if you need it: restore the backup from step 1. This loses everything done since the upgrade (messages, roles, private channels, custom status). Don't move the 0.6 data back instead: 0.5.0 would start on it, but 0.5.0 has no private channels, so every member could read every private channel's history, and read-only channels would be writable.
    1. In doghouse-0.6.0/deploy: docker compose down, then rename the 0.6 data so it is never used by mistake: mv data data-before-rollback-$(date +%F-%H%M%S).
    2. In doghouse-0.5.0/deploy: tar xzf ~/doghouse-backup-<date>.tgz (it puts back data and .env as they were before the upgrade). If you deleted that folder, unzip doghouse-0.5.0.zip into a fresh folder first and restore the backup in its deploy folder.
    3. In doghouse-0.5.0/deploy: docker compose up -d --build. Keep --build here: 0.5.0's compose file names its image doghouse-app:local, which is whatever you last built under that name, so only a rebuild makes sure it is 0.5.0. Settings then shows 0.5.0. (The 0.6.0 image stays under its own tag, so going forward to 0.6.0 again needs no rebuild.)
  6. Go through the real-device checklist in CHANGES-0.6.0.md.
  7. Old images pile up under their own tags. To free the disk once you're happy with 0.6.0: docker image rm doghouse-app:local (the 0.5.0 image; a rollback would rebuild it).

Tested: REQUIRE_LIVEKIT=1 npm run check is shared 340, server 834, web 1792, 0 failed. A full e2e run (REQUIRE_LIVEKIT=1 npm run e2e) is 136 passed, 122 skipped, 0 failed.

Troubleshooting

Notifications never arrive

  • The container needs outbound HTTPS to the push services (see "Push notifications"). Try docker compose exec app node -e "fetch('https://fcm.googleapis.com').then(r=>console.log(r.status),e=>console.log(String(e)))".
  • Settings > App and notifications > "Send test notification". Nothing there means no device is switched on.
  • A subscription the push service reports as gone (404/410) is deleted; switch the device on again.
  • The app's logs show push: rejected or push: no answer with the host (never keys or message text).

Voice doesn't connect ("Connecting…" forever, or drops after a few seconds)

  • Router forwards from step 2 present (UDP 20000-20100, TCP 7881, UDP 3478) and pointing at the right LAN IP.
  • docker compose logs livekit should show starting LiveKit server with your public IP as nodeIP. Without LIVEKIT_NODE_IP, LiveKit finds it with STUN (use_external_ip: true). If the log stops before that line (LiveKit can hang at startup while STUN times out), or shows a private IP, set LIVEKIT_NODE_IP=<your public IP> in .env (curl -4 ifconfig.me), then docker compose up -d livekit. Don't edit livekit.yaml for this.
  • https://doghouse.snoooopy.online/livekit/ in a browser should show OK. A 502 means NPM can't reach doghouse-livekit (check step 5: is NPM on doghouse_net?). A 404 means the Advanced block wasn't saved.
  • Voice needs HTTPS; it never works on http://.
  • "Voice isn't set up on this server yet" in the app = LIVEKIT_API_KEY/LIVEKIT_API_SECRET missing from .env.

LiveKit restarts over and over with:

could not validate RTC config: could not resolve external IP: dial udp: lookup stun1.l.google.com on 127.0.0.53:53: read udp 127.0.0.1:33500->127.0.0.53:53: read: connection refused
doghouse-livekit exited with code 0 (restarting)

LiveKit looks up your public IP with STUN at startup, and that DNS lookup failed. The fix:

  1. Put your public IP in .env: LIVEKIT_NODE_IP=203.0.113.10 (yours, from curl -4 ifconfig.me).
  2. docker compose up -d livekit. The log should now say doghouse: LIVEKIT_NODE_IP=…, skipping STUN and then starting LiveKit server with that nodeIP.

Then find out why DNS failed. 127.0.0.53 is the host's own resolver (systemd-resolved), which a container only sees when it runs in the host's network:

docker inspect doghouse-livekit --format '{{.HostConfig.NetworkMode}}'

This must say doghouse_net (or your DOGHOUSE_NETWORK), not host. Host mode also breaks NPM -> LiveKit (/livekit/ gives 502) and LiveKit -> app webhooks (voice participant lists go stale). Remove any network_mode: you added to docker-compose.yml and use DOGHOUSE_NETWORK in .env instead (step 5), then docker compose up -d.

docker compose up fails with "address already in use" on a UDP port, e.g.:

failed to bind host port [::]:50028/udp: address already in use

That port is inside Linux's ephemeral range (32768-60999), which the host hands out to outgoing connections, so something else already holds it. 0.1.1 used UDP 50000-50100 for voice media; since 0.1.2 it's 20000-20100, below that range. Use the shipped livekit.yaml and docker-compose.yml (the range is in both and they must match), move your router forwards and ufw rules to UDP 20000-20100 (step 2), then docker compose up -d livekit. Check what holds a port with sudo ss -ulpn | grep 20000.

Home IP changed (dynamic IP from your ISP): voice stops connecting while the site still works. Update LIVEKIT_NODE_IP in .env and run docker compose up -d livekit.

"413 Request Entity Too Large" when uploading - NPM's limit is lower than the file. Make sure the Advanced tab contains client_max_body_size 30m; (or more, matching MAX_UPLOAD_MB). Files over MAX_UPLOAD_MB get the app's own "too large" message instead.

Messages from others only appear after a reload - the WebSocket at /ws isn't getting through: turn on Websockets Support in the Details tab and save again.

502 Bad Gateway on the whole site - the app isn't running or NPM isn't on doghouse_net (or your DOGHOUSE_NETWORK): docker compose ps, docker compose logs app, docker network inspect doghouse_net (should list NPM, doghouse-app and doghouse-livekit).

App keeps restarting - docker compose logs app names the problem, e.g. a LiveKit secret shorter than 32 characters or a malformed PUBLIC_URL.

docker compose up says "set LIVEKIT_API_KEY in .env" - step 4 isn't done.

Login says "Cross-origin request blocked" - PUBLIC_URL in .env must exactly match the address in the browser (https://doghouse.snoooopy.online, no trailing slash).

Appendix: plain nginx instead of NPM

deploy/nginx-raw.conf is a complete server block for a self-managed nginx container on doghouse_net (certificates from certbot or similar). Unlike NPM it overwrites X-Forwarded-For and X-Real-IP with $remote_addr, proxies / and /ws to doghouse-app:3000 with WebSocket upgrade, /livekit/ to doghouse-livekit:7880 (prefix stripped), and sets client_max_body_size 30m. Skip step 7 when you use it.

Security notes

  • The app sends its own Content-Security-Policy (script-src 'self', connect-src limited to the site and LIVEKIT_PUBLIC_URL, frame-ancestors 'none'), X-Content-Type-Options, Referrer-Policy, Permissions-Policy (microphone, screen capture and, with VIDEO_ENABLED, camera for the site only; camera=() when video is off) and X-Frame-Options. Don't add a second CSP in NPM.
  • The app runs as an unprivileged user inside the container and isn't reachable except through NPM.

Development

Requirements

  • Node.js 20.19+ or 22 (production image will be node:22-alpine).
  • npm. npm install works with the committed package-lock.json. When adding or upgrading packages on the dev box, use npx -y npm@10 install ...: the Debian-packaged npm 9.2 crashes resolving new peer dependencies (arborist edgesOut bug).

Commands (from the repo root)

Command What it does
npm install Install all workspaces
npm run dev API on :3000 (tsx watch) + Vite on :5173 proxying /api and /ws
npm run check Typecheck (tsc + svelte-check) → ESLint + Prettier → Vitest (server with coverage, 80% gate), then a summary of passed/failed/skipped tests per suite and the coverage figures
npm run build Build packages/shared, apps/server/dist, apps/web/dist
npm start Run the built server; serves apps/web/dist (or ./public) with SPA fallback
npm run format Prettier write
npm run validate:deploy Static checks of deploy/ (YAML + compose-spec schema + the rules above); part of check
npm run package Build the server zip (+ .sha256) in dist/, from a clean git archive of HEAD; refuses to run if the working tree has any change. Named doghouse-<version>.zip only when HEAD is exactly on the tag v<version> (the version in package.json); any other commit gives doghouse-<version>.<hash>.zip, e.g. doghouse-0.2.0-dev.d95a1a1b2c.zip, where <hash> is the same 10-character build hash as in build.json. Never overwrites an existing zip in dist/ (it refuses; move the old one away first). Release builds also need CHANGES-<version>.md. The zip also gets build.json at its root (the one file not from git archive): the version, the first 10 characters of the commit hash and the commit time in UTC, so the same commit always gives the same zip, in any time zone. Settings > About, /api/health and /api/instance show it; a git checkout with no build.json uses git, and with neither the build is dev
npm run e2e Build, then run the Playwright smoke suite in e2e/ (desktop 1440×900 + phone 375×812) against a fresh data dir. Ports, screenshot and artifact folders come from env vars (E2E_PORT_BASE, E2E_LK_BASE, E2E_RTC_BASE, E2E_SHOTS_DIR, E2E_OUTPUT_DIR; see e2e/ports.mjs), so two runs can go at once on different values (use npm run e2e:only for the second: npm run e2e rebuilds dist). Uses CHROME_PATH, else system Chrome/Chromium, else npx playwright install chromium

Releasing

When you bump the version in the four workspace package.json files (and the lockfile), also bump the compose image tag in deploy/docker-compose.yml to doghouse-app:<version> in the same change. npm run check and npm run package fail if they don't match.

Layout

apps/server     Fastify + Socket.IO (/ws) + SQLite (better-sqlite3, WAL)
  src/db/migrations/*.sql   plain SQL migrations (full v1 data model)
  src/auth/permissions.ts   server-side authorization helpers (use these in every route)
apps/web        Svelte 5 + Vite, plain CSS; theme code in src/lib/theme
packages/shared zod schemas + DTO types shared by server and web

Server environment variables

Var Default Notes
APP_NAME Doghouse Shown in the page title and auth screens (served by /api/instance)
PUBLIC_URL https://doghouse.snoooopy.online The one origin users reach the app on
LIVEKIT_API_KEY / LIVEKIT_API_SECRET (empty) Must match LiveKit's keys. Set both or neither; the secret must be at least 32 characters. Empty = voice disabled (the voice view says so, /api/instance reports voiceEnabled: false)
LIVEKIT_URL http://doghouse-livekit:7880 Internal LiveKit address the app uses for the server API (list/remove participants, delete rooms)
LIVEKIT_PUBLIC_URL wss://doghouse.snoooopy.online/livekit LiveKit signalling URL handed to browsers, proxied under /livekit/ with the prefix stripped. Outside production, if unset, browsers use same-origin /livekit (the Vite proxy)
NODE_ENV (unset) production = strict Origin check: only PUBLIC_URL is accepted for POST/PATCH/PUT/DELETE and socket handshakes
PORT / HOST 3000 / 0.0.0.0
DATA_DIR ./data SQLite file chat.db and uploads/ live here
UPLOADS_DIR $DATA_DIR/uploads Uploaded files (random names, served only through the API)
MEDIA_DIR $DATA_DIR/media Avatars and banners (0.2+): one folder of WebP sizes per image, random ids, served only to logged-in users
DB_PATH $DATA_DIR/chat.db Override the DB file directly
STATIC_DIR auto ./public, then apps/web/dist
COOKIE_SECURE auto auto = Secure when the request came in over HTTPS (uses X-Forwarded-Proto); true/false to force
TRUST_PROXY_HOPS 1 Whole number of reverse-proxy hops to trust for X-Forwarded-* (QA-1). 1 = nginx, 0 = app reached directly, 2 = CDN in front of nginx. Never "true"
ALLOWED_ORIGINS (empty) Development only: extra origins allowed besides PUBLIC_URL and same-host. Ignored when NODE_ENV=production
SESSION_TTL_DAYS 30
RATE_LIMIT true Switches all the limits below on or off, including the pin, call-start and search limits. AUTH_RATE_LIMIT_MAX (10) per AUTH_RATE_LIMIT_WINDOW_MS (60000) per IP on login/register; it also covers the message, pin and unpin limits
MESSAGE_RATE_LIMIT_MAX / _WINDOW_MS 10 / 10000 Messages per user per window (edits/deletes ×2, reactions ×3, uploads ×1, separate buckets)
(fixed, follows RATE_LIMIT) 10 per minute Pin and unpin together, per person, across all chats; beyond that 429 too_many_pins ("You can pin or unpin at most 10 messages a minute") with Retry-After
(fixed, follows RATE_LIMIT) 10 per 10 minutes New DM and group calls started, per person (joining a call that is already going doesn't count); beyond that 429 too_many_calls with Retry-After. Before 0.5 this one stayed on with RATE_LIMIT=false (QA-101)
(fixed, follows RATE_LIMIT) 30 per minute Message searches, per person; beyond that 429 too_many_searches ("You can search at most 30 times a minute") with Retry-After
MAX_UPLOAD_MB 25 Upload limit in MB, 1-1024. Default and ceiling: admins can lower it via the API but not raise it above this, so the proxy's client_max_body_size (set a few MB higher) always fits
VIDEO_ENABLED true Webcams in voice channels and DM/group calls. false = no camera button, LiveKit tokens can't publish a camera (LiveKit refuses it), and Permissions-Policy: camera=(). One flag drives all three. See "Bandwidth" below
VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY generated Push notification key pair. Empty = generated on first start into $DATA_DIR/vapid.json (mode 0600). Set both or neither. Changing keys makes every device switch notifications on again
PUSH_ENDPOINT_ALLOW empty Extra push-service hosts (comma separated, host or *.suffix). Defaults: fcm.googleapis.com, *.push.apple.com, updates.push.services.mozilla.com, *.push.services.mozilla.com, *.notify.windows.com. Only https, no port, never an IP or internal name
PUSH_TEST_ORIGINS empty Tests only: read only when NODE_ENV=test (the e2e suite points pushes at a local mock). Ignored in production; leave it out of .env
CALL_RING_TIMEOUT_MS 30000 How long a DM/group call rings before it ends as a missed call (1000-300000; tests shorten it)
PRESENCE_GRACE_MS 10000 How long after a user's last socket disconnects before they show as offline (a reload or brief network drop doesn't flicker). Dead connections are noticed within ~20 s by Socket.IO pings
LOG_LEVEL info

Uploaded JPEG/PNG/GIF/WebP images are re-encoded with sharp (orientation applied, EXIF/GPS/XMP removed, animations kept, 50 MP limit); images that don't decode are rejected with 400. Other files are stored byte-for-byte. sharp ships prebuilt binaries for glibc and musl (node:22-alpine), so no build tools are needed.

Voice and screen share (LiveKit)

  • POST /api/voice/:channelId/token issues a 10-minute token for room voice_<channelId> (identity = user id): mic + screen share (+ its audio), plus camera only when VIDEO_ENABLED is on; no data channel, no room admin. 404 if you can't see the channel, 400 for a text channel.
  • DM and group calls (0.2): POST /api/dms/:dmId/call starts the DM's call (or returns the one already going: one active call per DM, enforced by a unique index) and rings every open tab of every other member (call:ring; no push notifications). POST /api/dms/:dmId/call/token gives a token for room call_<dmId> to current members only (404 otherwise, like voice). POST /api/calls/:id/accept|decline|leave and GET /api/calls (what's active / ringing for you). Unanswered after CALL_RING_TIMEOUT_MS (30 s) = "Missed call" system message; an answered call ends with "…'s call ended after N minutes". Removing someone from a group drops them from its call at once. One call or voice channel per person at a time.
  • Bandwidth (webcams): LiveKit forwards a copy of every camera to every viewer, so your home connection's upload is the limit. The app uses simulcast (180p/360p/full layers), adaptive stream and dynacast, so small tiles get the small layer and hidden tiles get nothing. Rough guide: five people on camera in a grid need about 5-10 Mbps of server upload; screen share adds 1-3 Mbps per viewer. If calls stutter, set VIDEO_ENABLED=false (voice and screen share keep working) and docker compose up -d.
  • POST /api/livekit/webhook (LiveKit signs it with the API key/secret; unsigned or forged = 401) keeps the in-memory "who's in voice" state that is pushed as voice:state. On startup the app rebuilds that state from LiveKit (listRooms/listParticipants). Kick, ban or losing access removes the person from the call; deleting a voice channel deletes its room.
  • Local dev: download livekit-server (GitHub releases; tested with v1.13.9) and run livekit-server --dev --keys "devkey: <32+ character secret>" --node-ip <your LAN IP> (the built-in dev secret secret is shorter than the app's 32-character minimum). Set LIVEKIT_API_KEY, LIVEKIT_API_SECRET, LIVEKIT_URL=http://localhost:7880 for the API; Vite proxies /livekit to LIVEKIT_DEV_URL (default http://localhost:7880) with the prefix stripped. Chrome won't connect over loopback-only ICE candidates, hence --node-ip/rtc.node_ip. --dev sends no webhooks, so the voice roster stays empty unless you use a config file with webhook.urls: [http://localhost:3000/api/livekit/webhook] (as e2e/livekit.mjs does).
  • e2e: e2e/tests/voice.spec.ts and e2e/tests/calls.spec.ts run Chromes with fake mic, camera and screen against a real LiveKit when the binary is found. The e2e suite starts two app instances: :3199 (ring timeout 10 s) and :3197 with VIDEO_ENABLED=false and its own LiveKit (7895/7896, proxy :3196, media UDP 21200-21300) to check that LiveKit itself refuses a camera. The binary is found (LIVEKIT_BIN, /workspace/tools/livekit-server or PATH); otherwise it skips. E2E_LIVEKIT=0 forces the skip; E2E_LIVEKIT_NODE_IP overrides the advertised IP. If LIVEKIT_BIN is set, only that path is used.
  • apps/server/test/livekit.integration.test.ts (part of npm run check) starts the same binary and checks the app's real LiveKit API calls (startup rebuild, deleteRoom, removeParticipant).
  • REQUIRE_LIVEKIT=1: nothing LiveKit-related may skip. npm run check fails (the integration test throws "REQUIRE_LIVEKIT=1 but no livekit-server binary was found…") and npm run e2e fails (the e2e server exits, and the voice spec errors if voice is disabled) when the binary isn't available. Use it in CI and for release sign-off: REQUIRE_LIVEKIT=1 npm run check && REQUIRE_LIVEKIT=1 npm run e2e. Without it, skipped tests are still listed by name in the check summary.