| ... | @@ -0,0 +1,79 @@ |
| 1 | amends "../../config/Service.pkl" |
| 2 | |
| 3 | import "../postgres/service.pkl" as postgres |
| 4 | |
| 5 | local host = module.container.http.hostname |
| 6 | |
| 7 | name = "Spacebar" |
| 8 | tagline = "Discord-compatible chat" |
| 9 | launcher = false |
| 10 | stageIsolation = "fresh" |
| 11 | healthyDeadline = "10m" |
| 12 | |
| 13 | requirements { |
| 14 | new postgres.Database { name = "spacebar" } |
| 15 | } |
| 16 | |
| 17 | secrets { |
| 18 | ["jwt_secret"] {} |
| 19 | ["request_signature"] {} |
| 20 | ["cdn_signature"] {} |
| 21 | } |
| 22 | |
| 23 | container { |
| 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 | } |