This commit is contained in:
Daniel Berteaud 2023-12-21 22:13:43 +01:00
parent cd8c0c78df
commit a981387910
4 changed files with 20 additions and 20 deletions

View File

@ -1,7 +1,7 @@
[[ $c := merge .bgm . -]] [[ $c := merge .bgm . -]]
job [[ .bgm.instance | toJSON ]] { job [[ .instance | toJSON ]] {
[[- template "common/job_start.tpl" $c ]] [[- template "common/job_start" $c ]]
group "boardgame-manager" { group "boardgame-manager" {
network { network {
@ -9,23 +9,23 @@ job [[ .bgm.instance | toJSON ]] {
} }
service { service {
name = "[[ .bgm.instance ]][[ $c.consul.suffix ]]" name = "[[ .instance ]][[ $c.consul.suffix ]]"
port = 8080 port = 8080
[[ template "common/connect.tpl" $c ]] [[ template "common/connect" $c ]]
tags = [ tags = [
"[[ $c.traefik.instance ]].enable=true", "[[ $c.traefik.instance ]].enable=true",
"[[ $c.traefik.instance ]].http.routers.[[ .bgm.instance ]][[ $c.consul.suffix ]].rule=Host(`[[ (urlParse .bgm.public_url).Hostname ]]`) "[[ $c.traefik.instance ]].http.routers.[[ .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 ]]", [[- 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.[[ .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.routers.[[ .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:", "[[ $c.traefik.instance ]].http.middlewares.[[ .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) ]] [[- 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.middlewares.[[ .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 ]]", "[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ $c.consul.suffix ]].middlewares=[[ .instance ]][[ $c.consul.suffix ]]-path,[[ .instance ]]-csp[[ $c.consul.suffix ]],[[ template "common/traefik_middlewares" $c.traefik ]]",
[[- else ]] [[- 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 ]]", "[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ $c.consul.suffix ]].middlewares=[[ .instance ]]-csp[[ $c.consul.suffix ]],[[ template "common/traefik_middlewares" $c.traefik ]]",
[[- end ]] [[- end ]]
] ]
} }
@ -60,7 +60,7 @@ job [[ .bgm.instance | toJSON ]] {
} }
env { env {
[[ template "common/env.tpl" $c.env ]] [[ template "common/env" $c.env ]]
} }
volume_mount { volume_mount {
@ -68,7 +68,7 @@ job [[ .bgm.instance | toJSON ]] {
destination = "/opt/bgm/databases" destination = "/opt/bgm/databases"
} }
[[ template "common/resources.tpl" .bgm.resources ]] [[ template "common/resources" .bgm.resources ]]
} }
@ -110,7 +110,7 @@ _EOT
volume = "backup" volume = "backup"
destination = "/backup" destination = "/backup"
} }
[[ template "common/resources.tpl" .bgm.backup.resources ]] [[ template "common/resources" .bgm.backup.resources ]]
} }
[[- end ]] [[- end ]]
} }

View File

@ -1,3 +1,3 @@
Kind = "service-defaults" Kind = "service-defaults"
Name = "[[ .bgm.instance ]][[ .consul.suffix ]]" Name = "[[ .instance ]][[ .consul.suffix ]]"
Protocol = "http" Protocol = "http"

View File

@ -1,5 +1,5 @@
Kind = "service-intentions" Kind = "service-intentions"
Name = "[[ .bgm.instance ]][[ .consul.suffix ]]" Name = "[[ .instance ]][[ .consul.suffix ]]"
Sources = [ Sources = [
{ {
Name = "[[ (merge .bgm .).traefik.instance ]]" Name = "[[ (merge .bgm .).traefik.instance ]]"

View File

@ -1,12 +1,12 @@
--- ---
# Name of the instance
instance: boardgame-manager
bgm: bgm:
# Name of the instance
instance: boardgame-manager
# Image to use # Image to use
image: danielberteaud/boardgame-manager:latest image: '[[ .docker.repo ]]boardgame-manager:latest'
# Resource allocation for the container # Resource allocation for the container
resources: resources: