authoravatarclover caruso<git@paperclover.net>2026-11-20 23:09:22-08:00
committeravatarclover caruso<git@paperclover.net>2026-11-22 00:44:03-08:00
log7726a5e9e056f72c4b74bba42fcf935bf69dc5e3
treeb48aabbe14d161773a0349ad4a648b4cc1c5d78d
parentc87873b304450f3f0b1fea2bcf63ba59af51b869
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Add Spacebar, a Discord-compatible chat server

Single all-in-one container on spacebar.<domain> backed by a Postgres database, with attachments on the service dataset. Config is rendered read-only from Pkl with the JWT and signature secrets from Nomad variables. Voice (WebRTC) is not exposed. Assisted-by: claude-sonnet-5.5

1 files changed, 79 insertions(+), 0 deletions(-)

service/spacebar/service.pkl created+79
......@@ -0,0 +1,79 @@
1amends "../../config/Service.pkl"
2
3import "../postgres/service.pkl" as postgres
4
5local host = module.container.http.hostname
6
7name = "Spacebar"
8tagline = "Discord-compatible chat"
9launcher = false
10stageIsolation = "fresh"
11healthyDeadline = "10m"
12
13requirements {
14 new postgres.Database { name = "spacebar" }
15}
16
17secrets {
18 ["jwt_secret"] {}
19 ["request_signature"] {}
20 ["cdn_signature"] {}
21}
22
23container {
24 image = "ghcr.io/spacebarchat/server@sha256:f50099777cee98d2d92290c792825ad02d705263253fae60d7b7e1f74fce46bb"
25 cpu = 300
26
27 http {
28 containerPort = 3001
29 subdomain = "spacebar"
30 checkPath = "/api/ping"
31 forwardRealIp = true
32 }
33
34 volumes {
35 ["/data"] {}
36 }
37
38 env {
39 ["CONFIG_PATH"] = "/spacebar/config.json"
40 ["CONFIG_READONLY"] = "true"
41 ["STORAGE_LOCATION"] = "/data/files"
42 ["PORT"] = "3001"
43 }
44
45 envTemplate = """
46 {{ with $db := nomadVar "nomad/jobs/\(module.id)/inputs/database" }}{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "postgres" }}DATABASE=postgres://{{ index $db "username" }}:{{ index $db "password" }}@\(module.nomadHostPort)/{{ index $db "name" }}{{ end }}{{ end }}
47 """
48
49 secretFiles {
50 ["/spacebar/config.json"] = """
51 {
52 "general": {
53 "instanceName": "Snow Globe",
54 "serverName": "\(host)"
55 },
56 "api": {
57 "endpointPublic": "https://\(host)/api/v9"
58 },
59 "cdn": {
60 "endpointPublic": "https://\(host)",
61 "endpointPrivate": "http://127.0.0.1:3001"
62 },
63 "gateway": {
64 "endpointPublic": "wss://\(host)"
65 },
66 "register": {
67 "requireCaptcha": false
68 },
69 "security": {
70 "forwardedFor": "X-Real-Ip",
71 "trustedProxies": "loopback,linklocal,uniquelocal",
72 "jwtSecret": "{{ with $own := nomadVar "nomad/jobs/\(module.id)" }}{{ index $own "jwt_secret" }}{{ end }}",
73 "requestSignature": "{{ with $own := nomadVar "nomad/jobs/\(module.id)" }}{{ index $own "request_signature" }}{{ end }}",
74 "cdnSignatureKey": "{{ with $own := nomadVar "nomad/jobs/\(module.id)" }}{{ index $own "cdn_signature" }}{{ end }}"
75 }
76 }
77 """
78 }
79}