vaultwarden/vaultwarden.nomad.hcl

88 lines
2.1 KiB
HCL
Raw Permalink Normal View History

[[ $c := merge .vaultwarden.server .vaultwarden . -]]
2023-12-21 23:32:14 +01:00
job "[[ .instance ]]" {
2023-11-01 22:51:13 +01:00
2023-12-21 23:32:14 +01:00
[[ template "common/job_start" $c ]]
2023-11-01 22:51:13 +01:00
group "vaultwarden" {
count = [[ $c.count ]]
network {
mode = "bridge"
}
[[ template "common/volumes" $c.volumes ]]
2023-11-01 22:51:13 +01:00
service {
2023-12-21 23:32:14 +01:00
name = "[[ .instance ]][[ .consul.suffix ]]"
2023-11-01 22:51:13 +01:00
port = 8234
2023-12-21 23:32:14 +01:00
[[ template "common/connect" $c ]]
2023-11-01 22:51:13 +01:00
check {
type = "http"
path = "/alive"
expose = true
2024-05-12 21:26:59 +02:00
[[ template "common/check_settings" $c ]]
2023-11-01 22:51:13 +01:00
check_restart {
limit = 20
grace = "20s"
}
}
tags = [
[[- $a := merge .vaultwarden.admin .vaultwarden . ]]
2024-01-27 00:11:39 +01:00
[[ template "common/traefik_tags" $a ]]
[[ template "common/traefik_tags" $c ]]
2023-11-01 22:51:13 +01:00
]
}
2023-12-21 23:32:14 +01:00
[[ template "common/task.wait_for" $c ]]
2024-01-15 21:34:12 +01:00
[[ template "common/task.pgpooler" $c ]]
2023-11-01 22:51:13 +01:00
task "vaultwarden" {
driver = [[ $c.nomad.driver | toJSON ]]
user = 8234
config {
image = [[ $c.image | toJSON ]]
pids_limit = 100
readonly_rootfs = true
}
[[ template "common/vault.policies" $c ]]
2024-03-27 13:20:27 +01:00
[[ template "common/artifacts" $c ]]
2023-11-01 22:51:13 +01:00
env {
ROCKET_ADDRESS = "127.0.0.1"
ROCKET_PORT = 8234
IP_HEADER = "X-Forwarded-for"
DOMAIN = [[ $c.public_url | toJSON ]]
DB_CONNECTION_RETRIES = 0
}
template {
data =<<_EOT
[[- if ne $c.postgres.pooler.engine "none" ]]
DATABASE_URL=postgresql://[[ .instance ]]:{{ env "NOMAD_ALLOC_ID" }}@localhost:[[ $c.postgres.pooler.port ]]/[[ $c.postgres.database ]]
[[- else ]]
DATABASE_URL=postgresql://[[ $c.postgres.user ]]:[[ $c.postgres.password | regexp.Replace "\\.Data\\.password" "urlquery .Data.password" ]]@[[ $c.postgres.host ]]:[[ $c.postgres.port ]]/[[ $c.postgres.database ]]]
[[- end ]]
_EOT
destination = "secrets/.db.env"
perms = 400
env = true
}
2024-03-02 22:13:47 +01:00
[[ template "common/file_env" $c ]]
2023-11-01 22:51:13 +01:00
volume_mount {
volume = "data"
destination = "/data"
}
2023-12-21 23:32:14 +01:00
[[ template "common/resources" $c.resources ]]
2023-11-01 22:51:13 +01:00
}
}
}