xonecas.io
8058
Ir

irvc / commit 37a32bc

feat: deploy docs and script

xonecas2026-10-11 37a32bc493f4c660505221ebdbc9ace11bb35dd5 parent 76dea00

7 files changed

.gitignore+7−0
@@ -12,3 +12,10 @@ web/dist/
1212 .env
1313 .env.*
1414 !.env.example
15+/deploy/irvc.env
16+/deploy/livekit.yaml
17+
18+# Runtime state
19+/irvc.db
20+/irvc.db-shm
21+/irvc.db-wal
AGENTS.md+6−0
@@ -7,3 +7,9 @@ With the lack of ownership of data, and more and more "enshitification" of these
77 the need is rising for a private self hosted instance of this.
88
99 This is ours.
10+
11+## Docs
12+
13+- `README.md` — build, configuration, invites, run.
14+- `irvc.md` — design.
15+- `DEPLOY.md` — runbook for the VPS deployment.
DEPLOY.md+143−0
@@ -0,0 +1,143 @@
1+# IRVC deployment
2+
3+Runbook for an IRVC instance on a VPS (Arch, no Docker). Design is in
4+[irvc.md](./irvc.md); the generic overview is in [README.md](./README.md).
5+Host-level config (DNS, Caddy, firewall) lives outside this repo.
6+
7+> **Replace the placeholders before running anything.** `<domain>` and `user`
8+> below stand in for your real domain and service account; `<hex>` and
9+> `<LIVEKIT_SECRET>` stand in for generated secrets. None of them work as-is.
10+
11+## Host plumbing (already done)
12+
13+- DNS: `irvc.<domain>` and `livekit.<domain>` — `A`/`AAAA` -> the host IP.
14+- Caddy: `irvc.<domain>` -> `127.0.0.1:8080`, `livekit.<domain>` ->
15+ `127.0.0.1:7880`. Certs issued.
16+- Firewall: TCP `22/80/443/7881`, UDP `50000-60000`.
17+
18+## Decisions
19+
20+Defaults chosen here; change before installing if you disagree.
21+
22+- Run both services as `user` (owns the checkout and the DB). No dedicated
23+ service users yet.
24+- Secrets live in `/etc/irvc.env` (root, `0600`), not in a shell profile.
25+- SQLite stays at `/home/user/repos/irvc/irvc.db` (WAL).
26+- `livekit-server` pinned to a release tag, installed to `/usr/local/bin`.
27+
28+## 1. LiveKit
29+
30+Fetch the release binary (assets are `livekit_<ver>_linux_amd64.tar.gz` under
31+tag `v<ver>`):
32+
33+ VERSION=1.13.9
34+ curl -fsSL -o /tmp/lk.tgz \
35+ https://github.com/livekit/livekit/releases/download/v$VERSION/livekit_${VERSION}_linux_amd64.tar.gz
36+ sudo tar -xzf /tmp/lk.tgz -C /usr/local/bin livekit-server
37+ livekit-server --version
38+
39+`/etc/livekit.yaml`:
40+
41+ port: 7880
42+ rtc:
43+ tcp_port: 7881
44+ port_range_start: 50000
45+ port_range_end: 60000
46+ use_external_ip: true
47+ keys:
48+ irvc: <LIVEKIT_SECRET>
49+
50+The host has its public IP directly on `eth0`, so `use_external_ip: true`
51+advertises the interface IP.
52+
53+`livekit-server` runs as `user` and reads this file itself, so hand it over:
54+
55+ sudo chown root:user /etc/livekit.yaml
56+ sudo chmod 640 /etc/livekit.yaml
57+
58+`/etc/systemd/system/livekit.service`:
59+
60+ [Unit]
61+ Description=LiveKit server
62+ After=network-online.target
63+ Wants=network-online.target
64+
65+ [Service]
66+ ExecStart=/usr/local/bin/livekit-server --config /etc/livekit.yaml
67+ User=user
68+ Restart=on-failure
69+ RestartSec=2
70+
71+ [Install]
72+ WantedBy=multi-user.target
73+
74+## 2. Secrets
75+
76+Generate two independent secrets:
77+
78+ openssl rand -hex 32 # IRVC_SESSION_SECRET
79+ openssl rand -hex 32 # LIVEKIT_SECRET (matches keys.irvc above)
80+
81+`/etc/irvc.env` (`sudo install -m 600 /dev/null /etc/irvc.env`, then edit):
82+
83+ IRVC_LISTEN_ADDR=127.0.0.1:8080
84+ IRVC_DB_PATH=/home/user/repos/irvc/irvc.db
85+ IRVC_SESSION_SECRET=<hex>
86+ IRVC_LIVEKIT_URL=wss://livekit.<domain>
87+ IRVC_LIVEKIT_API_KEY=irvc
88+ IRVC_LIVEKIT_SECRET=<hex>
89+
90+`IRVC_LISTEN_ADDR` binds loopback only, because Caddy fronts it. The Go server
91+mints the LiveKit JWT itself (`voice.go`) and never dials LiveKit — so
92+`IRVC_LIVEKIT_URL` is browser-facing, and only the key/secret must match
93+`/etc/livekit.yaml`.
94+
95+## 3. IRVC service
96+
97+`/etc/systemd/system/irvc.service`:
98+
99+ [Unit]
100+ Description=IRVC (Internet Relay Voice Chat)
101+ After=network-online.target
102+ Wants=network-online.target
103+
104+ [Service]
105+ WorkingDirectory=/home/user/repos/irvc
106+ ExecStart=/home/user/repos/irvc/irvc
107+ EnvironmentFile=/etc/irvc.env
108+ User=user
109+ Restart=on-failure
110+ RestartSec=2
111+
112+ [Install]
113+ WantedBy=multi-user.target
114+
115+`WorkingDirectory` is required: `serveFrontend` reads `web/dist` and the DB
116+path is relative, both resolved against the process CWD.
117+
118+## 4. Enable
119+
120+ sudo systemctl daemon-reload
121+ sudo systemctl enable --now livekit irvc
122+
123+## 5. Verify
124+
125+ systemctl status livekit irvc
126+ journalctl -u irvc -u livekit -f
127+ curl -sI https://irvc.<domain> # 200
128+ cd ~/repos/irvc && ./irvc invite # claim + log in
129+ curl -sI https://livekit.<domain> # 200 / 426, not 502
130+
131+First `irvc` start creates `irvc.db` and seeds `#general` (text) and `general`
132+(voice). Voice check: join `general`, confirm LiveKit logs the participant and
133+ICE completes over UDP.
134+
135+## Rebuild
136+
137+Only when code changes:
138+
139+ go build -o irvc .
140+ cd web && npm install && npm run build
141+
142+`web/dist` is served by the Go process; `~/repos/irvc/irvc` and `web/dist` are
143+gitignored build output.
README.md+2−1
@@ -1,7 +1,8 @@
11 # IRVC — Internet Relay Voice Chat
22
33 A WebRTC-powered text and voice chat. Private, self-hosted, personal server.
4-See [irvc.md](./irvc.md) for the design.
4+See [irvc.md](./irvc.md) for the design and [DEPLOY.md](./DEPLOY.md) for the
5+deployment runbook.
56
67 ## Architecture
78
deploy/install.sh+24−0
@@ -0,0 +1,24 @@
1+#!/usr/bin/env bash
2+# Installs the IRVC + LiveKit services. Run with sudo from this directory.
3+set -euo pipefail
4+
5+here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+caller="$(getent passwd "${SUDO_USER:-$USER}" | cut -d: -f6)"
7+lk_bin_src="$caller/.local/bin/livekit-server"
8+
9+[[ $EUID -eq 0 ]] || { echo "run with sudo" >&2; exit 1; }
10+[[ -x "$lk_bin_src" ]] || { echo "missing $lk_bin_src (download it first)" >&2; exit 1; }
11+for f in livekit.yaml irvc.env livekit.service irvc.service; do
12+ [[ -f "$here/$f" ]] || { echo "missing $here/$f" >&2; exit 1; }
13+done
14+
15+install -m 755 "$lk_bin_src" /usr/local/bin/livekit-server
16+install -o root -g user -m 640 "$here/livekit.yaml" /etc/livekit.yaml
17+install -o root -g root -m 600 "$here/irvc.env" /etc/irvc.env
18+install -m 644 "$here/livekit.service" /etc/systemd/system/livekit.service
19+install -m 644 "$here/irvc.service" /etc/systemd/system/irvc.service
20+
21+systemctl daemon-reload
22+systemctl enable --now livekit.service irvc.service
23+
24+systemctl --no-pager --full status livekit.service irvc.service || true
deploy/irvc.service+15−0
@@ -0,0 +1,15 @@
1+[Unit]
2+Description=IRVC (Internet Relay Voice Chat)
3+After=network-online.target
4+Wants=network-online.target
5+
6+[Service]
7+WorkingDirectory=/home/user/repos/irvc
8+ExecStart=/home/user/repos/irvc/irvc
9+EnvironmentFile=/etc/irvc.env
10+User=user
11+Restart=on-failure
12+RestartSec=2
13+
14+[Install]
15+WantedBy=multi-user.target
deploy/livekit.service+13−0
@@ -0,0 +1,13 @@
1+[Unit]
2+Description=LiveKit server
3+After=network-online.target
4+Wants=network-online.target
5+
6+[Service]
7+ExecStart=/usr/local/bin/livekit-server --config /etc/livekit.yaml
8+User=user
9+Restart=on-failure
10+RestartSec=2
11+
12+[Install]
13+WantedBy=multi-user.target