matrix/matrix.nomad.hcl

135 lines
3.3 KiB
HCL
Raw Normal View History

2024-01-19 15:51:08 +01:00
job "[[ .instance ]]" {
2024-04-09 13:05:14 +02:00
[[- $c := merge .matrix . -]]
2023-12-16 00:32:03 +01:00
[[ template "common/job_start" $c ]]
group "matrix" {
2024-04-09 13:05:14 +02:00
[[- $c := merge $c.synapse $c ]]
[[ template "common/group_start" $c ]]
2023-12-16 00:32:03 +01:00
network {
mode = "bridge"
[[- if conv.ToBool $c.prometheus.enabled ]]
port "metrics" {}
[[- end ]]
2023-12-16 00:32:03 +01:00
}
2024-01-19 15:51:08 +01:00
[[ template "common/volumes" $c ]]
2023-12-16 00:32:03 +01:00
service {
name = "[[ .instance ]][[ .consul.suffix ]]"
port = 8008
[[ template "common/service_meta" $c ]]
2023-12-16 00:32:03 +01:00
check {
type = "http"
path = "/health"
expose = true
interval = "10s"
timeout = "5s"
task = "synapse"
check_restart {
limit = 12
grace = "10m"
}
}
tags = [
2024-01-19 15:51:08 +01:00
[[- $w := merge .matrix.nginx .matrix . ]]
[[- $a := merge .matrix.nginx.admin $w ]]
2024-04-24 21:25:31 +02:00
[[- $sa := merge .matrix.nginx.synapse_admin $w ]]
2024-04-24 11:35:04 +02:00
"[[ $a.traefik.instance ]].http.routers.[[ .instance ]]-admin[[ .consul.suffix ]].rule=Host(`[[ (urlParse .matrix.public_url).Hostname ]]`) && PathPrefix(`/_synapse/admin`)",
2024-01-29 00:10:03 +01:00
[[ template "common/traefik_tags" $a ]]
2024-04-24 21:25:31 +02:00
"[[ $a.traefik.instance ]].http.routers.[[ .instance ]]-admin[[ .consul.suffix ]].rule=Host(`[[ (urlParse .matrix.public_url).Hostname ]]`) && PathPrefix(`/_admin`)",
[[ template "common/traefik_tags" $sa ]]
"[[ $w.traefik.instance ]].http.routers.[[ .instance ]][[ .consul.suffix ]].rule=Host(`[[ (urlParse .matrix.public_url).Hostname ]]`) || (Host(`[[ .matrix.server_name ]]`) && PathRegexp(`^/(_(synapse|matrix)|\\.well-known/matrix)/.*`))",
2024-01-29 00:10:03 +01:00
[[ template "common/traefik_tags" $w ]]
]
2024-01-31 14:50:08 +01:00
[[ template "common/connect" $c ]]
2023-12-16 00:32:03 +01:00
}
[[ template "common/task.wait_for" $c ]]
[[ template "common/task.metrics_proxy" $c ]]
2024-01-15 21:33:05 +01:00
[[ template "common/task.pgpooler" $c ]]
2023-12-16 00:32:03 +01:00
task "synapse" {
2024-01-19 15:51:08 +01:00
driver = "[[ $c.nomad.driver ]]"
2023-12-16 00:32:03 +01:00
leader = true
config {
2024-01-19 15:51:08 +01:00
image = "[[ $c.image ]]"
2023-12-16 00:32:03 +01:00
pids_limit = 200
readonly_rootfs = true
}
2024-01-11 23:21:01 +01:00
[[ template "common/vault.policies" $c ]]
2023-12-16 00:32:03 +01:00
env {
SYNAPSE_CONFIG = "/secrets/homeserver.yml"
2024-01-31 14:50:08 +01:00
TMPDIR = "/data/tmp"
2023-12-16 00:32:03 +01:00
}
2024-01-31 14:50:08 +01:00
[[ template "common/file_env" $c ]]
2023-12-16 00:32:03 +01:00
template {
data =<<_EOT
2024-01-11 23:21:01 +01:00
[[ (merge $c.config ((tmpl.Exec "matrix/homeserver.yml.tpl" $c) | yaml)) | toYAML ]]
2023-12-16 00:32:03 +01:00
_EOT
destination = "secrets/homeserver.yml"
uid = 100000
gid = 108008
perms = 0640
}
template {
data =<<_EOT
[[ template "matrix/logging.conf.tpl" . ]]
_EOT
destination = "secrets/logging.conf"
}
2023-12-16 00:32:03 +01:00
volume_mount {
volume = "data"
destination = "/data"
}
2024-01-19 15:51:08 +01:00
[[ template "common/resources" $c ]]
2023-12-16 00:32:03 +01:00
}
[[ $c = merge .matrix.nginx . ]]
task "nginx" {
2024-01-19 15:51:08 +01:00
driver = "[[ $c.nomad.driver ]]"
2023-12-16 00:32:03 +01:00
config {
2024-01-19 15:51:08 +01:00
image = "[[ $c.image ]]"
2023-12-16 00:32:03 +01:00
readonly_rootfs = true
pids_limit = 100
volumes = [
"local/nginx.conf:/etc/nginx/conf.d/default.conf:ro",
2023-12-16 00:32:03 +01:00
]
2024-01-19 15:51:08 +01:00
[[ template "common/tmpfs" dict "size" "5000000" "target" "/tmp" ]]
2023-12-16 00:32:03 +01:00
}
template {
data =<<_EOT
2024-01-19 15:51:08 +01:00
[[ template "matrix/nginx.conf.tpl" $c ]]
2023-12-16 00:32:03 +01:00
_EOT
destination = "local/nginx.conf"
}
template {
data =<<_EOT
2024-01-19 15:51:08 +01:00
[[ template "matrix/element.json.tpl" $c ]]
_EOT
destination = "local/element.json"
}
2024-01-19 15:51:08 +01:00
[[ template "common/resources" $c ]]
2023-12-16 00:32:03 +01:00
}
}
}