job "[[ .instance ]]" { [[- $c := merge .oo . ]] [[ template "common/job_start" $c ]] group "onlyoffice" { [[- $c := merge .oo.ds $c ]] [[ template "common/group_start" $c ]] 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 = "[[ .instance ]][[ $c.consul.suffix ]]" } [[ template "common/volumes" $c ]] service { name = "[[ .instance ]][[ $c.consul.suffix ]]" port = 8819 [[ template "common/service_meta" $c ]] [[ template "common/connect" $c ]] check { name = "health" type = "http" path = "/healthcheck" expose = true [[ template "common/check_settings" $c ]] check_restart { limit = 15 grace = "2m" } } tags = [ [[ template "common/traefik_tags" $c ]] ] } task "docserver" { driver = "[[ $c.nomad.driver ]]" leader = true config { [[ template "common/image" $c ]] pids_limit = 200 volumes = [ "local/:/tmp", "local/metrics.js:/var/www/onlyoffice/documentserver/server/Metrics/config/config.js:ro" ] } [[ template "common/vault.policies" $c ]] env { NGINX_LISTEN_IP = "127.0.0.1" APPLICATION_NAME = "[[ .instance ]][[ .consul.suffix ]]" WAIT_FOR_TARGETS = "127.0.0.1:5672" [[ template "common/proxy_env" $c ]] } [[ template "common/file_env" $c ]] # Database settings template { data =<<_EOT OO_DB_NAME='[[ $c.postgres.database ]]' [[- if ne $c.postgres.pooler.engine "none" ]] OO_DB_HOST=127.0.0.1 OO_DB_PORT=[[ $c.postgres.pooler.port ]] OO_DB_USER=[[ .instance ]] OO_DB_PASS={{ env "NOMAD_ALLOC_ID" }} [[- else ]] OO_DB_HOST=[[ $c.postgres.host ]] OO_DB_PORT=[[ $c.postgres.port ]] OO_DB_USER=[[ $c.postgres.user ]] OO_DB_PASS=[[ $c.postgres.password ]] [[- end ]] _EOT destination = "secrets/.db.env" uid = 100000 gid = 100000 perms = 400 env = true } template { data =<<_EOT [[ template "onlyoffice-docserver/metrics.js.tpl" . ]] _EOT destination = "local/metrics.js" } volume_mount { volume = "data" destination = "/var/lib/onlyoffice/documentserver/App_Data/" } [[ template "common/resources" $c ]] } [[ template "common/task.wait_for" $c ]] [[ template "common/task.pgpooler" $c ]] [[ template "common/task.redis" $c ]] [[ $c := merge .oo.rabbitmq . ]] task "rabbitmq" { driver = "[[ $c.nomad.driver ]]" lifecycle { hook = "prestart" sidecar = true } config { [[ template "common/image" $c ]] pids_limit = 100 volumes = [ "local/rabbitmq.conf:/etc/rabbitmq/conf.d/30-oods.conf" ] } [[ template "common/file_env" $c ]] template { data = <<_EOT listeners.tcp.1 = 127.0.0.1:5672 vm_memory_high_watermark.relative = 0.999 _EOT destination = "local/rabbitmq.conf" } volume_mount { volume = "rabbitmq" destination = "/var/lib/rabbitmq" } [[ template "common/resources" $c ]] } } }