147 lines
3.4 KiB
HCL
147 lines
3.4 KiB
HCL
job "[[ .instance ]]" {
|
|
|
|
[[ template "common/job_start" . ]]
|
|
|
|
group "navidrome" {
|
|
[[- $c := merge .navidrome . -]]
|
|
[[ template "common/group_start" $c ]]
|
|
|
|
network {
|
|
mode = "bridge"
|
|
[[- if conv.ToBool $c.prometheus.enabled ]]
|
|
port "metrics" {}
|
|
[[- end ]]
|
|
}
|
|
|
|
[[ template "common/volumes" $c ]]
|
|
|
|
[[- if and $c.backup.enabled (not (eq $c.backup.cron "")) ]]
|
|
[[ template "common/volumes" $c.backup ]]
|
|
[[- end ]]
|
|
|
|
service {
|
|
name = "[[ .instance ]][[ .consul.suffix ]]"
|
|
port = 4533
|
|
|
|
[[ template "common/service_meta" $c ]]
|
|
[[ template "common/connect" $c ]]
|
|
|
|
check {
|
|
name = "health"
|
|
type = "http"
|
|
path = "/ping"
|
|
expose = true
|
|
[[ template "common/check_settings" $c ]]
|
|
check_restart {
|
|
limit = 20
|
|
grace = "20s"
|
|
}
|
|
}
|
|
|
|
# The music volume can be unavailable for several reason.
|
|
# One of them is if it's on a fuse volume and it starts getting "transport unavailable" errors
|
|
# In this case, the alloc should be restarted
|
|
check {
|
|
name = "music"
|
|
type = "script"
|
|
interval = "120s"
|
|
timeout = "7s"
|
|
task = "navidrome"
|
|
command = "sh"
|
|
args = [
|
|
"-c",
|
|
"ls /music/ > /dev/null"
|
|
]
|
|
check_restart {
|
|
limit = 5
|
|
grace = "30s"
|
|
}
|
|
}
|
|
|
|
tags = [
|
|
[[ template "common/traefik_tags" $c ]]
|
|
]
|
|
}
|
|
|
|
[[ template "common/task.metrics_proxy" $c ]]
|
|
|
|
task "navidrome" {
|
|
driver = "[[ $c.nomad.driver ]]"
|
|
user = 4533
|
|
|
|
config {
|
|
[[ template "common/image" $c ]]
|
|
pids_limit = 100
|
|
}
|
|
|
|
env {
|
|
ND_MUSICFOLDER = "/music"
|
|
ND_DATAFOLDER = "/data"
|
|
ND_BASEURL = [[ (urlParse $c.public_url).Path | toJSON ]]
|
|
ND_ADDRESS = "127.0.0.1"
|
|
ND_REVERSEPROXYWHITELIST = "127.0.0.0/8"
|
|
[[- if and (conv.ToBool $c.prometheus.enabled) (not (has $c.env "ND_PROMETHEUS_ENABLED")) ]]
|
|
ND_PROMETHEUS_ENABLED = "true"
|
|
[[- end ]]
|
|
}
|
|
|
|
[[ template "common/file_env" $c ]]
|
|
|
|
volume_mount {
|
|
volume = "music"
|
|
destination = "/music"
|
|
read_only = true
|
|
}
|
|
|
|
volume_mount {
|
|
volume = "data"
|
|
destination = "/data"
|
|
}
|
|
|
|
[[ template "common/resources" $c ]]
|
|
}
|
|
|
|
[[- if and $c.backup.enabled (not (eq $c.backup.cron "")) ]]
|
|
[[- $c := merge .navidrome.backup .navidrome . ]]
|
|
task "backup" {
|
|
driver = "[[ $c.nomad.driver ]]"
|
|
|
|
lifecycle {
|
|
hook = "poststart"
|
|
sidecar = true
|
|
}
|
|
|
|
env {
|
|
MINIT_MAIN = "dump-sqlite /data/navidrome.db /backup"
|
|
MINIT_MAIN_KIND = "cron"
|
|
MINIT_MAIN_CRON = "[[ .navidrome.backup.cron ]]"
|
|
MINIT_MAIN_NAME = "navidrome-db-dump"
|
|
}
|
|
|
|
config {
|
|
image = "[[ .navidrome.backup.image ]]"
|
|
pids_limit = 50
|
|
readonly_rootfs = true
|
|
command = "minit"
|
|
}
|
|
|
|
# Mount the data volume readonly so we can read the DB
|
|
volume_mount {
|
|
volume = "data"
|
|
destination = "/data"
|
|
read_only = true
|
|
}
|
|
|
|
# Mount the backup volume
|
|
volume_mount {
|
|
volume = "backup"
|
|
destination = "/backup"
|
|
}
|
|
[[ template "common/resources" $c ]]
|
|
}
|
|
[[- end ]]
|
|
}
|
|
}
|
|
|
|
# vim: syntax=hcl
|