63 lines
2.5 KiB
HCL
63 lines
2.5 KiB
HCL
[[ $c := merge .bgm . -]]
|
|
job [[ .bgm.instance | toJSON ]] {
|
|
|
|
[[- template "common/job_start.tpl" $c ]]
|
|
|
|
group "boardgame-manager" {
|
|
network {
|
|
mode = "bridge"
|
|
}
|
|
|
|
service {
|
|
name = "[[ .bgm.instance ]][[ $c.consul.suffix ]]"
|
|
port = 8080
|
|
|
|
[[ template "common/connect.tpl" $c ]]
|
|
|
|
tags = [
|
|
"[[ $c.traefik.instance ]].enable=true",
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .bgm.instance ]][[ $c.consul.suffix ]].rule=Host(`[[ (urlParse .bgm.public_url).Hostname ]]`)
|
|
[[- if not (regexp.Match "^/?$" (urlParse .bgm.public_url).Path) ]] && PathPrefix(`[[ (urlParse .bgm.public_url).Path ]]`)[[ end ]]",
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .bgm.instance ]][[ $c.consul.suffix ]].entrypoints=[[ join $c.traefik.entrypoints "," ]]",
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .bgm.instance ]][[ $c.consul.suffix ]].tls=true",
|
|
"[[ $c.traefik.instance ]].http.middlewares.[[ .bgm.instance ]]-csp[[ $c.consul.suffix ]].headers.contentSecurityPolicy=default-src 'self'; img-src 'self' data: https://www.gravatar.com; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; font-src 'self' data:",
|
|
[[- if not (regexp.Match "^/?$" (urlParse .bgm.public_url).Path) ]]
|
|
"[[ $c.traefik.instance ]].http.middlewares.[[ .bgm.instance ]][[ $c.consul.suffix ]]-path.stripprefix.prefixes=[[ (urlParse .bgm.public_url).Path ]]",
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .bgm.instance ]][[ $c.consul.suffix ]].middlewares=[[ .bgm.instance ]][[ $c.consul.suffix ]]-path,[[ .bgm.instance ]]-csp[[ $c.consul.suffix ]],[[ template "common/traefik_middlewares.tpl" $c.traefik ]]",
|
|
[[- else ]]
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .bgm.instance ]][[ $c.consul.suffix ]].middlewares=[[ .bgm.instance ]]-csp[[ $c.consul.suffix ]],[[ template "common/traefik_middlewares.tpl" $c.traefik ]]",
|
|
[[- end ]]
|
|
]
|
|
}
|
|
|
|
volume "boardgame-manager" {
|
|
type = [[ .bgm.volumes.data.type | toJSON ]]
|
|
source = [[ .bgm.volumes.data.source | toJSON ]]
|
|
attachment_mode = "file-system"
|
|
access_mode = "single-node-writer"
|
|
}
|
|
|
|
task "boardgame-manager" {
|
|
driver = [[ $c.nomad.driver | toJSON ]]
|
|
|
|
config {
|
|
image = [[ .bgm.image | toJSON ]]
|
|
pids_limit = 100
|
|
readonly_rootfs = true
|
|
}
|
|
|
|
env {
|
|
[[ template "common/env.tpl" $c.env ]]
|
|
}
|
|
|
|
volume_mount {
|
|
volume = "boardgame-manager"
|
|
destination = "/opt/bgm/databases"
|
|
}
|
|
|
|
[[ template "common/resources.tpl" .bgm.resources ]]
|
|
|
|
}
|
|
}
|
|
}
|