onlyoffice-docserver/onlyoffice-docserver.nomad.hcl

176 lines
4.9 KiB
HCL
Raw Normal View History

2023-11-08 22:40:57 +01:00
[[ $c := merge .oo.ds . -]]
2023-12-21 23:06:48 +01:00
job [[ .instance | toJSON ]] {
2023-11-08 22:40:57 +01:00
2023-12-21 23:06:48 +01:00
[[ template "common/job_start" $c ]]
2023-11-08 22:40:57 +01:00
group "onlyoffice" {
network {
mode = "bridge"
# This can be used to ensure rabbitmq has a stable hostname
# Even if for now, we do not persist rabbitmq data
2023-12-21 23:06:48 +01:00
hostname = "[[ .instance ]][[ $c.consul.suffix ]]"
2023-11-08 22:40:57 +01:00
}
2023-12-21 23:06:48 +01:00
[[ template "common/volumes" .oo.volumes ]]
2023-11-08 22:40:57 +01:00
service {
2023-12-21 23:06:48 +01:00
name = "[[ .instance ]][[ $c.consul.suffix ]]"
2023-11-11 00:13:30 +01:00
port = 8819
2023-11-08 22:40:57 +01:00
2023-12-21 23:06:48 +01:00
[[ template "common/connect" $c ]]
2023-11-08 22:40:57 +01:00
check {
2023-11-11 00:13:30 +01:00
name = "health"
type = "http"
path = "/healthcheck"
expose = true
2023-11-08 22:40:57 +01:00
interval = "10s"
2023-11-11 00:13:30 +01:00
timeout = "8s"
2023-11-08 22:40:57 +01:00
check_restart {
2023-11-11 00:56:43 +01:00
limit = 30
2023-11-08 22:40:57 +01:00
grace = "2m"
}
}
tags = [
[[- if $c.traefik.enabled ]]
"[[ $c.traefik.instance ]].enable=true",
2023-12-21 23:06:48 +01:00
"[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ $c.consul.suffix ]].rule=Host(`[[ (urlParse .oo.ds.public_url).Hostname ]]`)
2023-11-08 22:40:57 +01:00
[[- if not (regexp.Match "^/?$" (urlParse .oo.ds.public_url).Path) ]] && PathPrefix(`[[ (urlParse .oo.ds.public_url).Path ]]`)[[ end ]]",
2023-12-21 23:06:48 +01:00
"[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ $c.consul.suffix ]].entrypoints=[[ join $c.traefik.entrypoints "," ]]",
"[[ $c.traefik.instance ]].http.middlewares.[[ .instance ]]-headers[[ $c.consul.suffix ]].headers.contentsecuritypolicy=[[ range $k, $v := $c.traefik.csp ]][[ $k ]] [[ $v ]];[[ end ]]",
"[[ $c.traefik.instance ]].http.middlewares.[[ .instance ]]-headers[[ $c.consul.suffix ]].headers.customrequestheaders.X-Forwarded-Proto=https",
2023-11-08 22:40:57 +01:00
[[- if not (regexp.Match "^/?$" (urlParse .oo.ds.public_url).Path) ]]
2023-12-21 23:06:48 +01:00
"[[ $c.traefik.instance ]].http.middlewares.[[ .instance ]][[ $c.consul.suffix ]]-prefix.stripprefix.prefixes=[[ (urlParse .oo.ds.public_url).Path ]]",
"[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ $c.consul.suffix ]].middlewares=[[ .instance ]]-headers[[ $c.consul.suffix ]],[[ .instance ]][[ $c.consul.suffix ]]-prefix,[[ template "common/traefik_middlewares" $c.traefik ]]",
2023-11-08 22:40:57 +01:00
[[- else ]]
2023-12-21 23:06:48 +01:00
"[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ $c.consul.suffix ]].middlewares=[[ .instance ]]-headers[[ $c.consul.suffix ]],[[ template "common/traefik_middlewares" $c.traefik ]]",
2023-11-08 22:40:57 +01:00
[[- end ]]
[[- end ]]
]
}
2023-11-11 00:13:30 +01:00
task "docserver" {
2023-11-08 22:40:57 +01:00
driver = [[ $c.nomad.driver | toJSON ]]
leader = true
config {
2023-11-11 00:13:30 +01:00
image = [[ .oo.ds.image | toJSON ]]
pids_limit = 200
2023-11-08 22:40:57 +01:00
readonly_rootfs = true
2023-11-11 00:13:30 +01:00
volumes = [
2023-11-11 00:56:43 +01:00
"local/:/tmp",
2023-11-11 00:13:30 +01:00
"local/metrics.js:/var/www/onlyoffice/documentserver/server/Metrics/config/config.js:ro"
2023-11-08 22:40:57 +01:00
]
}
vault {
2023-12-21 23:06:48 +01:00
policies = ["[[ .instance ]][[ $c.consul.suffix ]]"]
2023-11-08 22:40:57 +01:00
disable_file = true
2023-11-11 00:13:30 +01:00
env = false
2023-11-08 22:40:57 +01:00
}
env {
2023-11-11 00:13:30 +01:00
NGINX_LISTEN_IP = "127.0.0.1"
2023-12-21 23:06:48 +01:00
APPLICATION_NAME = "[[ .instance ]][[ .consul.suffix ]]"
[[ template "common/proxy_env" $c ]]
2023-11-08 22:40:57 +01:00
}
2023-12-21 23:06:48 +01:00
[[ template "common/file_env" $c.env ]]
2023-11-08 22:40:57 +01:00
template {
data =<<_EOT
2023-11-11 00:13:30 +01:00
[[ template "onlyoffice-docserver/metrics.js.tpl" . ]]
2023-11-08 22:40:57 +01:00
_EOT
destination = "local/metrics.js"
}
volume_mount {
2023-11-11 00:13:30 +01:00
volume = "data"
destination = "/var/lib/onlyoffice/documentserver/App_Data/"
2023-11-08 22:40:57 +01:00
}
2023-12-21 23:06:48 +01:00
[[ template "common/resources" $c.resources ]]
2023-11-08 22:40:57 +01:00
}
2023-12-21 23:06:48 +01:00
[[ template "common/task.wait_for" $c ]]
2023-11-08 22:40:57 +01:00
task "redis" {
driver = [[ $c.nomad.driver | toJSON ]]
2023-11-11 00:13:30 +01:00
user = 2967
2023-11-08 22:40:57 +01:00
lifecycle {
2023-11-11 00:13:30 +01:00
hook = "prestart"
2023-11-08 22:40:57 +01:00
sidecar = true
}
config {
2023-11-11 00:13:30 +01:00
image = "redis:alpine"
pids_limit = 20
2023-11-08 22:40:57 +01:00
readonly_rootfs = true
2023-11-11 00:13:30 +01:00
args = ["/local/redis.conf"]
2023-11-08 22:40:57 +01:00
}
template {
data =<<_EOT
bind 127.0.0.1
maxmemory {{ env "NOMAD_MEMORY_LIMIT" | parseInt | subtract 5 }}mb
databases 1
save ""
appendonly no
_EOT
destination = "local/redis.conf"
}
resources {
2023-11-11 00:13:30 +01:00
cpu = 10
2023-11-08 22:40:57 +01:00
memory = 20
}
}
[[ $c := merge .oo.rabbitmq . ]]
task "rabbitmq" {
driver = [[ $c.nomad.driver | toJSON ]]
2023-11-11 00:13:30 +01:00
#user = 100
2023-11-08 22:40:57 +01:00
lifecycle {
2023-11-11 00:13:30 +01:00
hook = "prestart"
2023-11-08 22:40:57 +01:00
sidecar = true
}
config {
2023-11-11 00:13:30 +01:00
image = [[ $c.image | toJSON ]]
pids_limit = 100
2023-11-08 22:40:57 +01:00
readonly_rootfs = true
2023-11-11 00:13:30 +01:00
volumes = [
2023-11-08 22:40:57 +01:00
"local/rabbitmq.conf:/etc/rabbitmq/conf.d/30-oods.conf"
]
}
2023-12-21 23:06:48 +01:00
[[ template "common/file_env" $c.env ]]
2023-11-11 00:13:30 +01:00
2023-11-08 22:40:57 +01:00
template {
data = <<_EOT
listeners.tcp.1 = 127.0.0.1:5672
2023-11-11 00:13:30 +01:00
# Set watermark to 95% of the mem allocated to the container
#vm_memory_high_watermark.absolute = [[ mul .oo.rabbitmq.resources.memory 996147 ]]
vm_memory_high_watermark.relative = 0.999
2023-11-08 22:40:57 +01:00
_EOT
destination = "local/rabbitmq.conf"
}
2023-11-11 00:13:30 +01:00
volume_mount {
volume = "rabbitmq"
destination = "/var/lib/rabbitmq"
}
2023-11-08 22:40:57 +01:00
2023-12-21 23:06:48 +01:00
[[ template "common/resources" $c.resources ]]
2023-11-08 22:40:57 +01:00
}
}
}