102 lines
3.0 KiB
HCL
102 lines
3.0 KiB
HCL
[[- $c := merge .miniflux . -]]
|
|
|
|
job [[ .miniflux.instance | toJSON ]] {
|
|
|
|
[[ template "common/job_start.tpl" $c ]]
|
|
|
|
group "miniflux" {
|
|
|
|
count = [[ .miniflux.count ]]
|
|
|
|
network {
|
|
mode = "bridge"
|
|
[[- if $c.prometheus.enabled ]]
|
|
port "metrics" {}
|
|
[[- end ]]
|
|
}
|
|
|
|
ephemeral_disk {
|
|
size = 101
|
|
}
|
|
|
|
service {
|
|
name = "[[ .miniflux.instance ]][[ $c.consul.suffix ]]"
|
|
port = 8085
|
|
|
|
[[ template "common/prometheus_meta.tpl" $c ]]
|
|
|
|
[[ template "common/connect.tpl" $c ]]
|
|
|
|
check {
|
|
type = "http"
|
|
path = "/healthcheck"
|
|
expose = true
|
|
interval = "10s"
|
|
timeout = "3s"
|
|
|
|
check_restart {
|
|
limit = 20
|
|
grace = "20s"
|
|
}
|
|
}
|
|
|
|
tags = [
|
|
"[[ $c.traefik.instance ]].enable=true",
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .miniflux.instance ]][[ $c.consul.suffix ]].rule=Host(`[[ (urlParse .miniflux.public_url).Hostname ]]`)
|
|
[[- if not (regexp.Match "^/?$" (urlParse .miniflux.public_url).Path) ]] && PathPrefix(`[[ (urlParse .miniflux.public_url).Path ]]`)[[ end ]]",
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .miniflux.instance ]][[ $c.consul.suffix ]].entrypoints=[[ join $c.traefik.entrypoints "," ]]",
|
|
[[- if not (regexp.Match "^/?$" (urlParse .miniflux.public_url).Path) ]]
|
|
"[[ $c.traefik.instance ]].http.middlewares.[[ .miniflux.instance ]][[ $c.consul.suffix ]]-prefix.stripprefix.prefixes=[[ (urlParse .miniflux.public_url).Path ]]",
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .miniflux.instance ]][[ $c.consul.suffix ]].middlewares=[[ .miniflux.instance ]][[ $c.consul.suffix ]]-prefix,[[ template "common/traefik_middlewares.tpl" $c.traefik ]]",
|
|
[[- else ]]
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .miniflux.instance ]][[ $c.consul.suffix ]].middlewares=[[ template "common/traefik_middlewares.tpl" $c.traefik ]]",
|
|
[[- end ]]
|
|
]
|
|
}
|
|
|
|
[[- if $c.prometheus.enabled ]]
|
|
[[ template "common/task.metrics_proxy.tpl" $c ]]
|
|
[[- end ]]
|
|
|
|
task "miniflux" {
|
|
driver = [[ $c.nomad.driver | toJSON ]]
|
|
|
|
config {
|
|
image = [[ .miniflux.image | toJSON ]]
|
|
pids_limit = 100
|
|
readonly_rootfs = true
|
|
}
|
|
|
|
vault {
|
|
policies = ["[[ .miniflux.instance ]][[ $c.consul.suffix ]]"]
|
|
env = false
|
|
disable_file = true
|
|
}
|
|
|
|
env {
|
|
LISTEN_ADDR = "127.0.0.1:8085"
|
|
BASE_URL = [[ .miniflux.public_url | toJSON ]]
|
|
[[- if $c.prometheus.enabled ]]
|
|
METRICS_COLLECTOR = 1
|
|
[[- end ]]
|
|
[[ template "common/proxy_env.tpl" $c ]]
|
|
}
|
|
|
|
[[ template "common/file_env.tpl" $c.env ]]
|
|
|
|
template {
|
|
data =<<_EOT
|
|
{{ with secret "[[ .vault.prefix ]]database/creds/[[ .miniflux.instance ]]" }}
|
|
DATABASE_URL="host=localhost port=5432 user={{ .Data.username }} password='{{ .Data.password }}' dbname=[[ .miniflux.db.name ]] sslmode=disable"
|
|
{{ end }}
|
|
_EOT
|
|
destination = "secrets/miniflux.env"
|
|
perms = 400
|
|
env = true
|
|
}
|
|
|
|
[[ template "common/resources.tpl" .miniflux.resources ]]
|
|
}
|
|
}
|
|
}
|