immich/example/immich.nomad.hcl

398 lines
8.9 KiB
HCL
Raw Normal View History

2024-01-05 14:06:26 +01:00
job "immich" {
2024-01-19 09:38:49 +01:00
2024-01-05 14:06:26 +01:00
datacenters = ["dc1"]
2024-02-24 09:33:54 +01:00
region = "global"
2024-01-05 14:06:26 +01:00
2024-03-28 22:49:05 +01:00
2024-01-05 14:06:26 +01:00
group "immich" {
network {
mode = "bridge"
}
volume "data" {
source = "immich-data"
type = "csi"
access_mode = "multi-node-multi-writer"
2024-01-05 14:06:26 +01:00
attachment_mode = "file-system"
}
service {
name = "immich"
port = 3001
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "immich-ml"
local_bind_port = 3003
2024-02-12 13:35:25 +01:00
# Work arround, see https://github.com/hashicorp/nomad/issues/18538
destination_type = "service"
config {
protocol = "http"
}
2024-01-05 14:06:26 +01:00
}
upstreams {
destination_name = "postgres"
local_bind_port = 5432
2024-02-12 13:35:25 +01:00
# Work arround, see https://github.com/hashicorp/nomad/issues/18538
destination_type = "service"
2024-01-05 14:06:26 +01:00
}
}
}
sidecar_task {
2024-01-28 23:17:47 +01:00
config {
args = [
"-c",
"${NOMAD_SECRETS_DIR}/envoy_bootstrap.json",
"-l",
"${meta.connect.log_level}",
"--concurrency",
"${meta.connect.proxy_concurrency}",
"--disable-hot-restart"
]
}
2024-01-23 11:48:20 +01:00
2024-01-05 14:06:26 +01:00
resources {
cpu = 50
memory = 64
}
}
}
check {
type = "http"
path = "/api/server-info/ping"
expose = true
interval = "30s"
timeout = "15s"
check_restart {
limit = 10
grace = "300s"
}
}
tags = [
2024-01-28 23:17:47 +01:00
2024-01-05 14:06:26 +01:00
"traefik.enable=true",
2024-01-28 23:17:47 +01:00
"traefik.http.routers.immich.entrypoints=https",
2024-01-31 13:50:03 +01:00
"traefik.http.routers.immich.rule=Host(`immich.example.org`)",
2024-01-31 23:27:14 +01:00
"traefik.http.middlewares.csp-immich.headers.contentsecuritypolicy=connect-src 'self' https://maputnik.github.io https://*.cofractal.com https://fonts.openmaptiles.org;default-src 'self';font-src 'self' data:;img-src 'self' data: blob:;script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';",
2024-01-31 13:50:03 +01:00
"traefik.http.routers.immich.middlewares=security-headers@file,forward-proto@file,inflight-std@file,hsts@file,compression@file,csp-immich",
2024-01-28 23:17:47 +01:00
"traefik.enable=true",
2024-01-05 14:06:26 +01:00
"traefik.http.routers.immich-share.entrypoints=https",
2024-02-26 22:32:57 +01:00
"traefik.http.routers.immich-share.rule=Host(`immich.example.org`) && PathRegexp(`^/(share/|_app/immutable/|custom\\.css|api/(asset|server-info)/.*)`)",
2024-01-31 23:27:14 +01:00
"traefik.http.middlewares.csp-immich-share.headers.contentsecuritypolicy=connect-src 'self' https://maputnik.github.io https://*.cofractal.com https://fonts.openmaptiles.org;default-src 'self';font-src 'self' data:;img-src 'self' data: blob:;script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';",
2024-01-31 13:50:03 +01:00
"traefik.http.routers.immich-share.middlewares=security-headers@file,forward-proto@file,inflight-std@file,hsts@file,compression@file,csp-immich-share",
2024-01-05 14:06:26 +01:00
]
}
# wait for required services tp be ready before starting the main task
task "wait-for" {
driver = "docker"
user = 1053
config {
2024-03-05 14:49:53 +01:00
image = "danielberteaud/wait-for:24.3-1"
2024-01-05 14:06:26 +01:00
readonly_rootfs = true
pids_limit = 20
}
lifecycle {
hook = "prestart"
}
env {
SERVICE_0 = "master.postgres.service.consul"
SERVICE_1 = "immich-ml.service.consul"
}
resources {
cpu = 10
memory = 10
memory_max = 30
}
}
2024-01-09 11:32:44 +01:00
2024-01-12 22:52:34 +01:00
2024-01-05 14:06:26 +01:00
# The main immich API server
task "server" {
driver = "docker"
leader = true
# Run as an unprivileged user
user = 3001
config {
2024-03-28 22:49:05 +01:00
image = "ghcr.io/immich-app/immich-server:v1.100.0"
2024-01-05 14:06:26 +01:00
readonly_rootfs = true
command = "start.sh"
args = ["immich"]
pids_limit = 100
}
2024-01-09 11:32:44 +01:00
2024-01-05 14:06:26 +01:00
vault {
policies = ["immich"]
env = false
disable_file = true
change_mode = "noop"
2024-01-05 14:06:26 +01:00
}
2024-01-09 11:32:44 +01:00
2024-01-05 14:06:26 +01:00
env {
REDIS_HOSTNAME = "127.0.0.1"
IMMICH_MEDIA_LOCATION = "/data"
}
2024-03-20 16:30:24 +01:00
2024-01-05 14:06:26 +01:00
# Use a template block instead of env {} so we can fetch values from vault
template {
data = <<_EOT
LANG=fr_FR.utf8
NODE_OPTIONS=--max-old-space-size={{ env "NOMAD_MEMORY_LIMIT" }}
TZ=Europe/Paris
_EOT
destination = "secrets/.env"
perms = 400
env = true
}
2024-01-09 11:32:44 +01:00
template {
data = <<_EOT
2024-03-05 14:49:53 +01:00
DB_URL=postgres://{{ with secret "database/creds/immich" }}{{ .Data.username }}{{ end }}:{{ with secret "database/creds/immich" }}{{ .Data.password }}{{ end }}@127.0.0.1:5432/immich
2024-01-09 11:32:44 +01:00
_EOT
destination = "secrets/.db.env"
perms = 400
env = true
}
2024-01-05 14:06:26 +01:00
volume_mount {
volume = "data"
destination = "/data"
}
2024-01-23 11:48:20 +01:00
2024-01-05 14:06:26 +01:00
resources {
cpu = 300
memory = 320
memory_max = 512
}
}
# microservices is tha task worker, doing all the processing async
task "microservices" {
driver = "docker"
# Run as an unpriviliged user
user = 3001
config {
2024-03-28 22:49:05 +01:00
image = "ghcr.io/immich-app/immich-server:v1.100.0"
2024-01-05 14:06:26 +01:00
readonly_rootfs = true
command = "start.sh"
args = ["microservices"]
pids_limit = 100
}
2024-01-09 11:32:44 +01:00
2024-01-05 14:06:26 +01:00
vault {
policies = ["immich"]
env = false
disable_file = true
change_mode = "noop"
2024-01-05 14:06:26 +01:00
}
2024-01-09 11:32:44 +01:00
2024-01-05 14:06:26 +01:00
env {
REDIS_HOSTNAME = "127.0.0.1"
IMMICH_MEDIA_LOCATION = "/data"
}
2024-03-20 16:30:24 +01:00
2024-01-05 14:06:26 +01:00
# Use a template block instead of env {} so we can fetch values from vault
template {
data = <<_EOT
LANG=fr_FR.utf8
NODE_OPTIONS=--max-old-space-size={{ env "NOMAD_MEMORY_LIMIT" }}
TZ=Europe/Paris
_EOT
destination = "secrets/.env"
perms = 400
env = true
}
2024-01-09 11:32:44 +01:00
template {
data = <<_EOT
2024-03-05 14:49:53 +01:00
DB_URL=postgres://{{ with secret "database/creds/immich" }}{{ .Data.username }}{{ end }}:{{ with secret "database/creds/immich" }}{{ .Data.password }}{{ end }}@127.0.0.1:5432/immich
2024-01-09 11:32:44 +01:00
_EOT
destination = "secrets/.db.env"
perms = 400
env = true
}
2024-01-05 14:06:26 +01:00
volume_mount {
volume = "data"
destination = "/data"
}
2024-01-23 11:48:20 +01:00
2024-01-05 14:06:26 +01:00
resources {
cpu = 500
memory = 768
memory_max = 1200
2024-01-05 14:06:26 +01:00
}
}
2024-01-11 19:50:19 +01:00
# Local redis instance
2024-01-05 14:06:26 +01:00
task "redis" {
driver = "docker"
user = 6379
lifecycle {
hook = "prestart"
sidecar = true
}
config {
image = "redis:alpine"
readonly_rootfs = true
2024-01-11 19:50:19 +01:00
force_pull = true
2024-01-05 14:06:26 +01:00
args = ["/local/redis.conf"]
}
template {
data = <<_EOT
bind 127.0.0.1
maxmemory {{ env "NOMAD_MEMORY_LIMIT" | parseInt | subtract 5 }}mb
databases 1
save ""
appendonly no
_EOT
destination = "local/redis.conf"
}
resources {
cpu = 20
memory = 64
}
}
}
# Used for face recognition, tags etc.
group "machine-learning" {
network {
mode = "bridge"
}
volume "ml" {
source = "immich-ml"
type = "csi"
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
service {
name = "immich-ml"
port = 3003
connect {
sidecar_service {
}
sidecar_task {
2024-01-28 23:17:47 +01:00
config {
args = [
"-c",
"${NOMAD_SECRETS_DIR}/envoy_bootstrap.json",
"-l",
"${meta.connect.log_level}",
"--concurrency",
"${meta.connect.proxy_concurrency}",
"--disable-hot-restart"
]
}
2024-01-23 11:48:20 +01:00
2024-01-05 14:06:26 +01:00
resources {
cpu = 50
memory = 64
}
}
}
}
task "machine-learning" {
driver = "docker"
user = 3001
config {
2024-03-28 22:49:05 +01:00
image = "ghcr.io/immich-app/immich-machine-learning:v1.100.0"
2024-01-05 14:06:26 +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
}
2024-01-05 14:06:26 +01:00
2024-03-20 16:30:24 +01:00
2024-03-02 22:13:13 +01:00
# Use a template block instead of env {} so we can fetch values from vault
template {
data = <<_EOT
LANG=fr_FR.utf8
TZ=Europe/Paris
_EOT
destination = "secrets/.env"
perms = 400
env = true
2024-01-05 14:06:26 +01:00
}
2024-03-02 22:13:13 +01:00
2024-01-05 14:06:26 +01:00
volume_mount {
volume = "ml"
destination = "/cache"
}
2024-01-23 11:48:20 +01:00
2024-01-05 14:06:26 +01:00
resources {
cpu = 1024
memory = 1024
memory_max = 1536
2024-01-05 14:06:26 +01:00
}
}
}
}