From 7726a5e9e056f72c4b74bba42fcf935bf69dc5e3 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Fri, 20 Nov 2026 23:09:22 -0800 Subject: [PATCH] Add Spacebar, a Discord-compatible chat server Single all-in-one container on spacebar. 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 --- service/spacebar/service.pkl | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 service/spacebar/service.pkl diff --git a/service/spacebar/service.pkl b/service/spacebar/service.pkl new file mode 100644 index 0000000000000000000000000000000000000000..7ea853b1f3f8ee085b041205cb97b1b40932fc90 --- /dev/null +++ b/service/spacebar/service.pkl @@ -0,0 +1,79 @@ +amends "../../config/Service.pkl" + +import "../postgres/service.pkl" as postgres + +local host = module.container.http.hostname + +name = "Spacebar" +tagline = "Discord-compatible chat" +launcher = false +stageIsolation = "fresh" +healthyDeadline = "10m" + +requirements { + new postgres.Database { name = "spacebar" } +} + +secrets { + ["jwt_secret"] {} + ["request_signature"] {} + ["cdn_signature"] {} +} + +container { + image = "ghcr.io/spacebarchat/server@sha256:f50099777cee98d2d92290c792825ad02d705263253fae60d7b7e1f74fce46bb" + cpu = 300 + + http { + containerPort = 3001 + subdomain = "spacebar" + checkPath = "/api/ping" + forwardRealIp = true + } + + volumes { + ["/data"] {} + } + + env { + ["CONFIG_PATH"] = "/spacebar/config.json" + ["CONFIG_READONLY"] = "true" + ["STORAGE_LOCATION"] = "/data/files" + ["PORT"] = "3001" + } + + envTemplate = """ + {{ 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 }} + """ + + secretFiles { + ["/spacebar/config.json"] = """ + { + "general": { + "instanceName": "Snow Globe", + "serverName": "\(host)" + }, + "api": { + "endpointPublic": "https://\(host)/api/v9" + }, + "cdn": { + "endpointPublic": "https://\(host)", + "endpointPrivate": "http://127.0.0.1:3001" + }, + "gateway": { + "endpointPublic": "wss://\(host)" + }, + "register": { + "requireCaptcha": false + }, + "security": { + "forwardedFor": "X-Real-Ip", + "trustedProxies": "loopback,linklocal,uniquelocal", + "jwtSecret": "{{ with $own := nomadVar "nomad/jobs/\(module.id)" }}{{ index $own "jwt_secret" }}{{ end }}", + "requestSignature": "{{ with $own := nomadVar "nomad/jobs/\(module.id)" }}{{ index $own "request_signature" }}{{ end }}", + "cdnSignatureKey": "{{ with $own := nomadVar "nomad/jobs/\(module.id)" }}{{ index $own "cdn_signature" }}{{ end }}" + } + } + """ + } +} -- 2.54.1