onlyoffice-docserver/onlyoffice-docserver.nomad.hcl

192 lines
5.6 KiB
HCL
Raw Normal View History

2023-11-08 22:40:57 +01:00
[[ $c := merge .oo.ds . -]]
job [[ .oo.instance | toJSON ]] {
[[ template "common/job_start.tpl" $c ]]
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
hostname = "[[ .oo.instance ]][[ $c.consul.suffix ]]"
}
2023-11-11 00:13:30 +01:00
volume "data" {
type = [[ .oo.volumes.data.type | toJSON ]]
source = [[ .oo.volumes.data.source | toJSON ]]
[[- if ne .oo.volumes.data.type "host" ]]
2023-11-11 00:13:30 +01:00
access_mode = "single-node-writer"
attachment_mode = "file-system"
[[- end ]]
2023-11-11 00:13:30 +01:00
}
volume "rabbitmq" {
type = [[ .oo.volumes.rabbitmq.type | toJSON ]]
source = [[ .oo.volumes.rabbitmq.source | toJSON ]]
[[- if ne .oo.volumes.rabbitmq.type "host" ]]
2023-11-11 00:13:30 +01:00
access_mode = "single-node-writer"
2023-11-08 22:40:57 +01:00
attachment_mode = "file-system"
[[- end ]]
2023-11-08 22:40:57 +01:00
}
service {
name = "[[ .oo.instance ]][[ $c.consul.suffix ]]"
2023-11-11 00:13:30 +01:00
port = 8819
2023-11-08 22:40:57 +01:00
[[ template "common/connect.tpl" $c ]]
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",
"[[ $c.traefik.instance ]].http.routers.[[ .oo.instance ]][[ $c.consul.suffix ]].rule=Host(`[[ (urlParse .oo.ds.public_url).Hostname ]]`)
[[- if not (regexp.Match "^/?$" (urlParse .oo.ds.public_url).Path) ]] && PathPrefix(`[[ (urlParse .oo.ds.public_url).Path ]]`)[[ end ]]",
"[[ $c.traefik.instance ]].http.routers.[[ .oo.instance ]][[ $c.consul.suffix ]].entrypoints=[[ join $c.traefik.entrypoints "," ]]",
2023-11-11 00:13:30 +01:00
"[[ $c.traefik.instance ]].http.middlewares.[[ .oo.instance ]]-headers[[ $c.consul.suffix ]].headers.contentsecuritypolicy=[[ range $k, $v := $c.traefik.csp ]][[ $k ]] [[ $v ]];[[ end ]]",
"[[ $c.traefik.instance ]].http.middlewares.[[ .oo.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) ]]
"[[ $c.traefik.instance ]].http.middlewares.[[ .oo.instance ]][[ $c.consul.suffix ]]-prefix.stripprefix.prefixes=[[ (urlParse .oo.ds.public_url).Path ]]",
2023-11-11 00:13:30 +01:00
"[[ $c.traefik.instance ]].http.routers.[[ .oo.instance ]][[ $c.consul.suffix ]].middlewares=[[ .oo.instance ]]-headers[[ $c.consul.suffix ]],[[ .oo.instance ]][[ $c.consul.suffix ]]-prefix,[[ template "common/traefik_middlewares.tpl" $c.traefik ]]",
2023-11-08 22:40:57 +01:00
[[- else ]]
2023-11-11 00:13:30 +01:00
"[[ $c.traefik.instance ]].http.routers.[[ .oo.instance ]][[ $c.consul.suffix ]].middlewares=[[ .oo.instance ]]-headers[[ $c.consul.suffix ]],[[ template "common/traefik_middlewares.tpl" $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-11-11 00:13:30 +01:00
policies = ["[[ .oo.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"
APPLICATION_NAME = "[[ .oo.instance ]][[ .consul.suffix ]]"
2023-11-08 22:40:57 +01:00
[[ template "common/proxy_env.tpl" $c ]]
}
[[ template "common/file_env.tpl" $c.env ]]
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
}
[[ template "common/resources.tpl" $c.resources ]]
}
[[ template "common/task.wait_for.tpl" $c ]]
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-11-11 00:13:30 +01:00
[[ template "common/file_env.tpl" $c.env ]]
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
[[ template "common/resources.tpl" $c.resources ]]
}
}
}