141 lines
3.7 KiB
HCL
141 lines
3.7 KiB
HCL
job "[[ .instance ]]" {
|
|
[[ template "common/job_start" . ]]
|
|
|
|
group "plausible" {
|
|
[[- $c := merge .plausible . ]]
|
|
[[ template "common/group_start" $c ]]
|
|
|
|
network {
|
|
mode = "bridge"
|
|
[[- if conv.ToBool $c.metrics.enabled ]]
|
|
port "metrics" {}
|
|
[[- end ]]
|
|
}
|
|
|
|
[[ template "common/volumes" merge $c.clickhouse $c ]]
|
|
|
|
service {
|
|
name = "[[ .instance ]][[ .consul.suffix ]]"
|
|
port = 8000
|
|
[[ template "common/service_meta" $c ]]
|
|
[[ template "common/connect" $c ]]
|
|
|
|
check {
|
|
name = "health"
|
|
type = "http"
|
|
path = "/api/health"
|
|
expose = true
|
|
[[ template "common/check_settings" $c ]]
|
|
check_restart {
|
|
limit = 10
|
|
grace = "15m"
|
|
}
|
|
}
|
|
|
|
tags = [
|
|
[[ template "common/traefik_tags" merge $c.events $c ]]
|
|
[[ template "common/traefik_tags" merge $c.server $c ]]
|
|
]
|
|
}
|
|
|
|
[[ template "common/task.wait_for" $c ]]
|
|
[[ template "common/task.chown_volumes" merge $c.clickhouse $c ]]
|
|
[[ template "common/task.pgbouncer" $c ]]
|
|
[[ template "common/task.proxmox_backup" $c ]]
|
|
[[ template "common/task.metrics_proxy" $c ]]
|
|
[[ template "common/task.socat_proxy" $c ]]
|
|
|
|
task "clickhouse" {
|
|
[[- $d := merge $c.clickhouse $c ]]
|
|
driver = "[[ $d.nomad.driver ]]"
|
|
|
|
lifecycle {
|
|
hook = "prestart"
|
|
sidecar = true
|
|
}
|
|
|
|
config {
|
|
image = "[[ $d.image ]]"
|
|
pids_limit = 1000
|
|
ulimit {
|
|
nofile = "262144:262144"
|
|
}
|
|
volumes = [
|
|
"local/clickhouse.xml:/etc/clickhouse-server/config.d/docker_related_config.xml:ro",
|
|
]
|
|
}
|
|
|
|
env {
|
|
CLICKHOUSE_DB = "plausible_events_db"
|
|
CLICKHOUSE_SKIP_USER_SETUP = "1"
|
|
}
|
|
|
|
template {
|
|
data = <<_EOT
|
|
[[ template "plausible/clickhouse.xml" $d ]]
|
|
_EOT
|
|
destination = "local/clickhouse.xml"
|
|
}
|
|
|
|
[[ template "common/artifacts" $d ]]
|
|
[[ template "common/templates" $d ]]
|
|
[[ template "common/volumes_mount" $d ]]
|
|
[[ template "common/resources" $d ]]
|
|
}
|
|
|
|
task "plausible" {
|
|
[[- $e := merge $c.server $c ]]
|
|
driver = "[[ $e.nomad.driver ]]"
|
|
leader = true
|
|
|
|
config {
|
|
[[ template "common/image" $e ]]
|
|
pids_limit = 500
|
|
command = "sh"
|
|
args = [
|
|
"-c",
|
|
"/entrypoint.sh db migrate && /entrypoint.sh run"
|
|
]
|
|
}
|
|
|
|
env {
|
|
LISTEN_IP = "127.0.0.1"
|
|
HTTP_PORT = 8000
|
|
ERL_EPMD_ADDRESS = "127.0.0.1"
|
|
ERL_MAX_PORTS = 1024
|
|
RELEASE_VM_ARGS = "/local/vm.args"
|
|
RELEASE_TMP = "/local/tmp"
|
|
TMPDIR = "/local/tmp"
|
|
}
|
|
|
|
[[ template "common/file_env" $e ]]
|
|
|
|
template {
|
|
data = <<_EOT
|
|
CLICKHOUSE_DATABASE_URL=http://127.0.0.1:8123/plausible_events_db
|
|
[[- if ne $c.postgres.pooler.engine "none" ]]
|
|
DATABASE_URL=postgresql://[[ .instance ]]:{{ env "NOMAD_ALLOC_ID" }}@127.0.0.1:[[ $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/.env.db"
|
|
uid = [[ 0 | add $e.docker.userns.uid_shift ]]
|
|
gid = [[ 0 | add $e.docker.userns.gid_shift ]]
|
|
perms = 400
|
|
env = true
|
|
}
|
|
|
|
template {
|
|
data = "-kernel inet_dist_use_interface {127,0,0,1}"
|
|
destination = "local/vm.args"
|
|
}
|
|
|
|
[[ template "common/vault.policies" $e ]]
|
|
[[ template "common/artifacts" $e ]]
|
|
[[ template "common/templates" $e ]]
|
|
[[ template "common/resources" $e ]]
|
|
}
|
|
}
|
|
}
|