immich/immich.nomad.hcl

188 lines
4.1 KiB
HCL
Raw Permalink Normal View History

2024-01-19 09:38:49 +01:00
job "[[ .instance ]]" {
2023-11-25 22:04:47 +01:00
2024-01-19 09:38:49 +01:00
[[ $c := merge .immich . ]]
2023-11-25 22:04:47 +01:00
2024-01-19 09:38:49 +01:00
[[ template "common/job_start" $c ]]
2023-11-25 22:04:47 +01:00
2024-01-09 11:32:44 +01:00
[[ $c := merge .immich.server .immich . -]]
2023-11-25 22:04:47 +01:00
group "immich" {
network {
mode = "bridge"
}
[[ template "common/volumes" $c ]]
2023-11-25 22:04:47 +01:00
service {
2023-12-21 22:37:48 +01:00
name = "[[ .instance ]][[ .consul.suffix ]]"
2023-11-27 23:07:31 +01:00
port = 3001
2023-11-25 22:04:47 +01:00
2023-12-15 22:00:56 +01:00
[[ template "common/connect" $c ]]
2023-11-25 22:04:47 +01:00
2023-11-27 23:07:31 +01:00
check {
type = "http"
path = "/api/server-info/ping"
expose = true
2024-05-11 21:24:53 +02:00
[[ template "common/check_settings" $c ]]
2023-11-27 23:07:31 +01:00
check_restart {
limit = 10
grace = "300s"
}
}
2023-11-25 22:04:47 +01:00
tags = [
2024-01-28 23:17:47 +01:00
[[ template "common/traefik_tags" $c ]]
[[- $s := merge $c.share $c ]]
2024-01-31 13:50:03 +01:00
[[ template "common/traefik_tags" $s ]]
2023-11-25 22:04:47 +01:00
]
}
2023-12-15 22:00:56 +01:00
[[ template "common/task.wait_for" $c ]]
[[ template "common/task.pgpooler" $c ]]
2023-11-27 23:07:31 +01:00
# The main immich API server
2023-11-25 22:04:47 +01:00
task "server" {
2024-01-19 09:38:49 +01:00
driver = "[[ $c.nomad.driver ]]"
2023-11-25 22:04:47 +01:00
leader = true
2023-11-27 23:07:31 +01:00
# Run as an unprivileged user
user = 3001
2023-11-25 22:04:47 +01:00
config {
2024-01-19 09:38:49 +01:00
image = "[[ $c.image ]]"
2023-11-27 23:07:31 +01:00
readonly_rootfs = true
command = "start.sh"
args = ["immich"]
pids_limit = 100
2023-11-25 22:04:47 +01:00
}
2024-01-09 11:32:44 +01:00
[[ template "common/vault.policies" $c ]]
2023-11-25 22:04:47 +01:00
env {
2023-11-27 23:07:31 +01:00
REDIS_HOSTNAME = "127.0.0.1"
2023-11-25 22:04:47 +01:00
IMMICH_MEDIA_LOCATION = "/data"
}
[[ template "common/file_env" $c ]]
2023-11-25 22:04:47 +01:00
2024-01-09 11:32:44 +01:00
template {
data =<<_EOT
DB_URL=postgres://
2024-01-12 22:52:34 +01:00
[[- if ne $c.postgres.pooler.engine "none" -]]
[[ .instance ]]:{{ env "NOMAD_ALLOC_ID" }}@127.0.0.1:[[ $c.postgres.pooler.port ]]/[[ $c.postgres.database ]]
2024-01-09 11:32:44 +01:00
[[- else -]]
[[ $c.postgres.user ]]:[[ $c.postgres.password ]]@[[ $c.postgres.host ]]:[[ $c.postgres.port ]]/[[ $c.postgres.database ]]
[[- end ]]
_EOT
destination = "secrets/.db.env"
perms = 400
env = true
}
2023-11-25 22:04:47 +01:00
volume_mount {
2024-01-19 09:38:49 +01:00
volume = "data"
2023-11-25 22:04:47 +01:00
destination = "/data"
}
[[ template "common/resources" $c ]]
2023-11-25 22:04:47 +01:00
}
2024-01-09 11:32:44 +01:00
[[ $c := merge .immich.microservices .immich . ]]
2023-11-27 23:07:31 +01:00
# microservices is tha task worker, doing all the processing async
2023-11-25 22:04:47 +01:00
task "microservices" {
2024-01-19 09:38:49 +01:00
driver = "[[ $c.nomad.driver ]]"
2023-11-27 23:07:31 +01:00
# Run as an unpriviliged user
user = 3001
2023-11-25 22:04:47 +01:00
config {
2024-01-19 09:38:49 +01:00
image = "[[ $c.image ]]"
2023-11-27 23:07:31 +01:00
readonly_rootfs = true
command = "start.sh"
args = ["microservices"]
pids_limit = 100
2023-11-25 22:04:47 +01:00
}
2024-01-09 11:32:44 +01:00
[[ template "common/vault.policies" $c ]]
2023-11-25 22:04:47 +01:00
env {
2023-11-27 23:07:31 +01:00
REDIS_HOSTNAME = "127.0.0.1"
2023-11-25 22:04:47 +01:00
IMMICH_MEDIA_LOCATION = "/data"
}
[[ template "common/file_env" $c ]]
2023-11-25 22:04:47 +01:00
2024-01-09 11:32:44 +01:00
template {
data =<<_EOT
DB_URL=postgres://
2024-01-12 22:52:34 +01:00
[[- if ne $c.postgres.pooler.engine "none" -]]
2024-01-09 11:32:44 +01:00
[[ .instance ]]:{{ env "NOMAD_ALLOC_ID" }}@127.0.0.1:6432/[[ $c.postgres.database ]]
[[- else -]]
[[ $c.postgres.user ]]:[[ $c.postgres.password ]]@[[ $c.postgres.host ]]:[[ $c.postgres.port ]]/[[ $c.postgres.database ]]
[[- end ]]
_EOT
destination = "secrets/.db.env"
perms = 400
env = true
}
2023-11-25 22:04:47 +01:00
volume_mount {
2023-11-27 23:07:31 +01:00
volume = "data"
2023-11-25 22:04:47 +01:00
destination = "/data"
}
[[ template "common/resources" $c ]]
2023-11-25 22:04:47 +01:00
}
2024-04-11 23:30:56 +02:00
[[ template "common/task.redis" $c ]]
2023-11-25 22:04:47 +01:00
}
2023-11-27 23:07:31 +01:00
[[- if .immich.machine_learning.enabled ]]
2024-01-09 11:32:44 +01:00
[[- $c := merge .immich.machine_learning .immich . ]]
2023-11-27 23:07:31 +01:00
# Used for face recognition, tags etc.
group "machine-learning" {
network {
mode = "bridge"
}
[[ template "common/volumes" $c ]]
2023-11-27 23:07:31 +01:00
service {
2023-12-21 22:37:48 +01:00
name = "[[ .instance ]]-ml[[ .consul.suffix ]]"
2023-11-27 23:07:31 +01:00
port = 3003
2023-12-15 22:00:56 +01:00
[[ template "common/connect" $c ]]
2023-11-27 23:07:31 +01:00
}
2024-01-09 11:32:44 +01:00
[[ $c := merge .immich.machine_learning .immich . ]]
2023-11-27 23:07:31 +01:00
task "machine-learning" {
2024-01-19 09:38:49 +01:00
driver = "[[ $c.nomad.driver ]]"
2023-11-27 23:07:31 +01:00
user = 3001
config {
2024-01-19 09:38:49 +01:00
image = "[[ $c.image ]]"
2023-11-27 23:07:31 +01:00
readonly_rootfs = true
pids_limit = 200
}
env {
TMPDIR = "/local"
MPLCONFIGDIR = "/local"
MACHINE_LEARNING_HOST = "127.0.0.1"
}
2024-03-02 22:13:13 +01:00
[[ template "common/file_env" $c ]]
2023-11-27 23:07:31 +01:00
volume_mount {
volume = "ml"
destination = "/cache"
}
[[ template "common/resources" $c ]]
2023-11-27 23:07:31 +01:00
}
}
[[- end ]]
2023-11-25 22:04:47 +01:00
}