1amends "../../config/Service.pkl"
2
3import "../../config/site.pkl" as site
4import "../../config/OpenID.pkl" as sso
5import "../forward-auth/service.pkl" as forwardAuth
6
7name = "Music"
8access = "media"
9stageIsolation = if (site.preview) "fresh" else "clone"
10
11requirements {
12 new sso.Client {
13 clientId = module.id
14 name = module.name
15 redirectUris { "https://\(module.containers["app"].http.hostname)/snow.oauth2/callback" }
16 }
17}
18
19secrets { ["cookie"] = forwardAuth.secrets["cookie"] }
20
21containers {
22 ["auth"] = (forwardAuth.container!!) {
23 lifecycle = "prestartSidecar"
24 hostNetwork = true
25 http = null
26 tcp { new { name = "oauth"; containerPort = 4180 } }
27 envTemplate = "OAUTH2_PROXY_HTTP_ADDRESS=127.0.0.1:{{ env \"NOMAD_PORT_auth_oauth\" }}"
28 env {
29 ["OAUTH2_PROXY_COOKIE_NAME"] = "_snow_\(module.id)"
30 ["OAUTH2_PROXY_COOKIE_DOMAINS"] = module.containers["app"].http.hostname!!
31 ["OAUTH2_PROXY_WHITELIST_DOMAINS"] = "\(module.containers["app"].http.hostname),\(sso.hostname)"
32 ["OAUTH2_PROXY_REDIRECT_URL"] = "https://\(module.containers["app"].http.hostname)/snow.oauth2/callback"
33 ["OAUTH2_PROXY_ALLOWED_GROUPS"] = "role:media"
34 ["OAUTH2_PROXY_AUTH_LOGGING"] = "false"
35 ["OAUTH2_PROXY_REQUEST_LOGGING"] = "false"
36 }
37 }
38 ["server"] {
39 image = "docker.io/deluan/navidrome@sha256:59ce76e6e06193fbfbb1736a93b8468227e1ea663fc7b25b1da13fbb97f5197b"
40 lifecycle = "prestartSidecar"
41 hostNetwork = true
42 volumes {
43 ["/data"] {}
44 ["/socket"] {}
45 ["/etc/ssl/certs/ca-certificates.crt"] { src = "/var/lib/snowglobe/ca-bundle.crt"; readOnly = true }
46 when (site.preview) { ["/music"] {} }
47 when (!site.preview) { ["/music"] { src = "\(site.mediaRoot)/Music"; readOnly = true } }
48 }
49 env {
50 ["ND_SCANNER_GROUPALBUMRELEASES"] = "1"
51 ["ND_BASEURL"] = "https://\(module.containers["app"].http.hostname)/"
52 ["ND_PID_ALBUM"] = "folder"
53 ["ND_EXTAUTH_USERHEADER"] = "Remote-User"
54 ["ND_EXTAUTH_TRUSTEDSOURCES"] = "@"
55 ["ND_ADDRESS"] = "unix:/socket/navidrome.sock"
56 when (site.preview) { ["ND_ENABLEEXTERNALSERVICES"] = "false" }
57 }
58 }
59 ["app"] {
60 image = "ghcr.io/jeffvli/feishin@sha256:6c75a4d3b99065ac245e2eb2b693fde3e5f2a6fe41c9e255da4fcb8948071965"
61 hostNetwork = true
62 entrypoint = "nginx"
63 args { "-g"; "daemon off;" }
64 cpu = 100
65 memory = 256
66 http { containerPort = 9180; loopback = true; subdomain = "music"; checkPath = "/snow-health" }
67 volumes {
68 ["/socket"] { readOnly = true }
69 ["/etc/nginx/conf.d/settings.js"] { config = "settings.js" }
70 ["/usr/share/nginx/html/snow-bootstrap.js"] { config = "bootstrap.js" }
71 }
72 secretFiles {
73 ["/etc/nginx/conf.d/default.conf"] = read("nginx.conf").text
74 .replaceAll("AUTH_SERVICE", "\(module.id)-auth")
75 }
76 }
77}