xonecas.io
8058
Ir

irvc / files

irvc / DEPLOY.md

4.2 KB
1# IRVC deployment
2
3Runbook 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).
5Host-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
20Defaults 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
30Fetch the release binary (assets are `livekit_<ver>_linux_amd64.tar.gz` under
31tag `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
50The host has its public IP directly on `eth0`, so `use_external_ip: true`
51advertises 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
76Generate 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
91mints 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
116path 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
131First `irvc` start creates `irvc.db` and seeds `#general` (text) and `general`
132(voice). Voice check: join `general`, confirm LiveKit logs the participant and
133ICE completes over UDP.
134
135## Rebuild
136
137Only 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
143gitignored build output.