paperless-ngx/example/paperless-ngx.nomad.hcl

454 lines
10 KiB
HCL
Raw Normal View History

2024-01-05 15:40:45 +01:00
job "paperless" {
datacenters = ["dc1"]
2024-02-16 09:36:14 +01:00
region = "global"
2024-01-05 15:40:45 +01:00
2024-03-28 23:13:42 +01:00
2024-01-05 15:40:45 +01:00
group "paperless" {
network {
mode = "bridge"
}
volume "data" {
type = "csi"
source = "paperless-data"
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
volume "input" {
type = "csi"
source = "paperless-input"
access_mode = "single-node-writer"
attachment_mode = "file-system"
}
service {
name = "paperless"
port = 8994
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "postgres"
local_bind_port = 5432
2024-02-13 10:49:52 +01:00
# Work arround, see https://github.com/hashicorp/nomad/issues/18538
destination_type = "service"
2024-01-05 15:40:45 +01:00
}
}
}
sidecar_task {
2024-01-26 23:51:31 +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-24 23:24:36 +01:00
2024-01-05 15:40:45 +01:00
resources {
cpu = 50
memory = 64
}
}
}
tags = [
2024-01-26 23:51:31 +01:00
2024-01-05 15:40:45 +01:00
"traefik.enable=true",
"traefik.http.routers.paperless.entrypoints=https",
2024-01-31 15:20:01 +01:00
"traefik.http.routers.paperless.rule=Host(`paperless.example.org`)",
"traefik.http.middlewares.csp-paperless.headers.contentsecuritypolicy=default-src 'self';font-src 'self' data:;img-src 'self' data:;script-src 'self' 'unsafe-inline' 'unsafe-eval';style-src 'self' 'unsafe-inline';",
"traefik.http.routers.paperless.middlewares=security-headers@file,rate-limit-std@file,forward-proto@file,inflight-std@file,hsts@file,compression@file,csp-paperless",
2024-01-26 23:51:31 +01:00
2024-01-05 15:40:45 +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 10:14:31 +01:00
image = "danielberteaud/wait-for:24.3-1"
2024-01-05 15:40:45 +01:00
readonly_rootfs = true
pids_limit = 20
}
lifecycle {
hook = "prestart"
}
env {
2024-01-11 15:51:06 +01:00
SERVICE_0 = "master.postgres.service.consul"
2024-01-05 15:40:45 +01:00
}
resources {
cpu = 10
memory = 10
memory_max = 30
}
}
2024-01-11 15:51:06 +01:00
# Local redis instance
2024-01-05 15:40:45 +01:00
task "redis" {
driver = "docker"
user = 6379
lifecycle {
hook = "prestart"
sidecar = true
}
config {
image = "redis:alpine"
readonly_rootfs = true
2024-01-11 15:51:06 +01:00
force_pull = true
2024-01-05 15:40:45 +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 = 10
memory = 20
}
}
2024-01-12 21:52:20 +01:00
2024-01-05 15:40:45 +01:00
task "webserver" {
driver = "docker"
config {
2024-03-18 10:00:07 +01:00
image = "danielberteaud/paperless-ngx:2.6.3-1"
2024-02-11 23:20:42 +01:00
image_pull_timeout = "10m"
readonly_rootfs = true
pids_limit = 200
2024-01-05 15:40:45 +01:00
}
2024-01-12 21:52:20 +01:00
2024-01-05 15:40:45 +01:00
vault {
policies = ["paperless"]
env = false
disable_file = true
2024-02-11 23:20:42 +01:00
change_mode = "noop"
2024-01-05 15:40:45 +01:00
}
2024-01-12 21:52:20 +01:00
2024-01-05 15:40:45 +01:00
env {
PAPERLESS_MODE = "webserver"
PAPERLESS_BIND_ADDR = "127.0.0.1"
PAPERLESS_TRUSTED_PROXIES = "127.0.0.1"
PAPERLESS_PROXY_SSL_HEADER = "[\"HTTP_X_FORWARDED_PROTO\", \"https\"]"
PAPERLESS_CONVERT_TMPDIR = "/alloc/data"
PAPERLESS_USE_X_FORWARD_HOST = "true"
PAPERLESS_URL = "https://paperless.example.org"
PAPERLESS_ENABLE_COMPRESSION = false
TMPDIR = "/alloc/tmp"
2024-01-05 15:40:45 +01:00
}
2024-03-18 10:00:07 +01:00
2024-01-05 15:40:45 +01:00
# Use a template block instead of env {} so we can fetch values from vault
template {
data = <<_EOT
LANG=fr_FR.utf8
PAPERLESS_CORS_ALLOWED_HOSTS=https://paperless.example.org
2024-03-05 15:00:27 +01:00
PAPERLESS_SECRET_KEY={{ with secret "kv/service/paperless" }}{{ .Data.data.secret_key }}{{ end }}
2024-01-05 15:40:45 +01:00
TZ=Europe/Paris
_EOT
destination = "secrets/.env"
perms = 400
env = true
}
2024-01-12 21:52:20 +01:00
template {
data = <<_EOT
PAPERLESS_DBHOST=127.0.0.1
PAPERLESS_DBPORT=5432
2024-03-05 15:00:27 +01:00
PAPERLESS_DBUSER={{ with secret "database/creds/paperless" }}{{ .Data.username }}{{ end }}
PAPERLESS_DBPASS={{ with secret "database/creds/paperless" }}{{ .Data.password }}{{ end }}
2024-01-12 21:52:20 +01:00
_EOT
destination = "secrets/.db.env"
perms = 400
env = true
}
2024-01-05 15:40:45 +01:00
volume_mount {
volume = "data"
destination = "/data"
}
volume_mount {
volume = "input"
destination = "/input"
}
2024-01-24 23:24:36 +01:00
2024-01-05 15:40:45 +01:00
resources {
cpu = 300
memory = 512
}
}
task "consumer" {
driver = "docker"
lifecycle {
2024-01-12 21:52:20 +01:00
hook = "poststart"
2024-01-05 15:40:45 +01:00
sidecar = true
}
config {
2024-03-18 10:00:07 +01:00
image = "danielberteaud/paperless-ngx:2.6.3-1"
2024-02-11 23:20:42 +01:00
image_pull_timeout = "10m"
readonly_rootfs = true
pids_limit = 100
2024-01-05 15:40:45 +01:00
}
2024-01-12 21:52:20 +01:00
2024-01-05 15:40:45 +01:00
vault {
policies = ["paperless"]
env = false
disable_file = true
2024-02-11 23:20:42 +01:00
change_mode = "noop"
2024-01-05 15:40:45 +01:00
}
2024-01-12 21:52:20 +01:00
2024-01-05 15:40:45 +01:00
env {
PAPERLESS_MODE = "consumer"
PAPERLESS_CONVERT_TMPDIR = "/alloc/data"
TMPDIR = "/alloc/tmp"
2024-01-05 15:40:45 +01:00
}
2024-03-18 10:00:07 +01:00
2024-01-05 15:40:45 +01:00
# Use a template block instead of env {} so we can fetch values from vault
template {
data = <<_EOT
LANG=fr_FR.utf8
PAPERLESS_CORS_ALLOWED_HOSTS=https://paperless.example.org
2024-03-05 15:00:27 +01:00
PAPERLESS_SECRET_KEY={{ with secret "kv/service/paperless" }}{{ .Data.data.secret_key }}{{ end }}
2024-01-05 15:40:45 +01:00
TZ=Europe/Paris
_EOT
destination = "secrets/.env"
perms = 400
env = true
}
2024-01-12 21:52:20 +01:00
template {
data = <<_EOT
PAPERLESS_DBHOST=127.0.0.1
PAPERLESS_DBPORT=5432
2024-03-05 15:00:27 +01:00
PAPERLESS_DBUSER={{ with secret "database/creds/paperless" }}{{ .Data.username }}{{ end }}
PAPERLESS_DBPASS={{ with secret "database/creds/paperless" }}{{ .Data.password }}{{ end }}
2024-01-12 21:52:20 +01:00
_EOT
destination = "secrets/.db.env"
perms = 400
env = true
}
2024-01-05 15:40:45 +01:00
volume_mount {
volume = "data"
destination = "/data"
}
volume_mount {
volume = "input"
destination = "/input"
}
2024-01-24 23:24:36 +01:00
2024-01-05 15:40:45 +01:00
resources {
cpu = 100
2024-01-19 10:16:07 +01:00
memory = 256
2024-01-05 15:40:45 +01:00
}
}
task "scheduler" {
driver = "docker"
lifecycle {
hook = "prestart"
sidecar = true
}
config {
2024-03-18 10:00:07 +01:00
image = "danielberteaud/paperless-ngx:2.6.3-1"
2024-02-11 23:20:42 +01:00
image_pull_timeout = "10m"
readonly_rootfs = true
pids_limit = 100
2024-01-05 15:40:45 +01:00
}
2024-01-12 21:52:20 +01:00
2024-01-05 15:40:45 +01:00
vault {
policies = ["paperless"]
env = false
disable_file = true
2024-02-11 23:20:42 +01:00
change_mode = "noop"
2024-01-05 15:40:45 +01:00
}
2024-01-12 21:52:20 +01:00
2024-01-05 15:40:45 +01:00
env {
PAPERLESS_MODE = "scheduler"
PAPERLESS_CONVERT_TMPDIR = "/alloc/data"
TMPDIR = "/alloc/tmp"
2024-01-05 15:40:45 +01:00
}
2024-03-18 10:00:07 +01:00
2024-01-05 15:40:45 +01:00
# Use a template block instead of env {} so we can fetch values from vault
template {
data = <<_EOT
LANG=fr_FR.utf8
PAPERLESS_CORS_ALLOWED_HOSTS=https://paperless.example.org
2024-03-05 15:00:27 +01:00
PAPERLESS_SECRET_KEY={{ with secret "kv/service/paperless" }}{{ .Data.data.secret_key }}{{ end }}
2024-01-05 15:40:45 +01:00
TZ=Europe/Paris
_EOT
destination = "secrets/.env"
perms = 400
env = true
}
2024-01-12 21:52:20 +01:00
template {
data = <<_EOT
PAPERLESS_DBHOST=127.0.0.1
PAPERLESS_DBPORT=5432
2024-03-05 15:00:27 +01:00
PAPERLESS_DBUSER={{ with secret "database/creds/paperless" }}{{ .Data.username }}{{ end }}
PAPERLESS_DBPASS={{ with secret "database/creds/paperless" }}{{ .Data.password }}{{ end }}
2024-01-12 21:52:20 +01:00
_EOT
destination = "secrets/.db.env"
perms = 400
env = true
}
2024-01-05 15:40:45 +01:00
volume_mount {
volume = "data"
destination = "/data"
}
volume_mount {
volume = "input"
destination = "/input"
}
2024-01-24 23:24:36 +01:00
2024-01-05 15:40:45 +01:00
resources {
cpu = 100
memory = 200
}
}
task "task-queue" {
driver = "docker"
lifecycle {
2024-01-12 21:52:20 +01:00
hook = "poststart"
2024-01-05 15:40:45 +01:00
sidecar = true
}
config {
2024-03-18 10:00:07 +01:00
image = "danielberteaud/paperless-ngx:2.6.3-1"
2024-02-11 23:20:42 +01:00
image_pull_timeout = "10m"
readonly_rootfs = true
pids_limit = 300
2024-01-05 15:40:45 +01:00
}
2024-01-12 21:52:20 +01:00
2024-01-05 15:40:45 +01:00
vault {
policies = ["paperless"]
env = false
disable_file = true
2024-02-11 23:20:42 +01:00
change_mode = "noop"
2024-01-05 15:40:45 +01:00
}
2024-01-12 21:52:20 +01:00
2024-01-05 15:40:45 +01:00
env {
PAPERLESS_MODE = "task-queue"
PAPERLESS_CONVERT_TMPDIR = "/alloc/data"
TMPDIR = "/alloc/tmp"
2024-01-05 15:40:45 +01:00
}
2024-03-18 10:00:07 +01:00
2024-01-05 15:40:45 +01:00
# Use a template block instead of env {} so we can fetch values from vault
template {
data = <<_EOT
LANG=fr_FR.utf8
PAPERLESS_CORS_ALLOWED_HOSTS=https://paperless.example.org
2024-03-05 15:00:27 +01:00
PAPERLESS_SECRET_KEY={{ with secret "kv/service/paperless" }}{{ .Data.data.secret_key }}{{ end }}
2024-01-05 15:40:45 +01:00
TZ=Europe/Paris
_EOT
destination = "secrets/.env"
perms = 400
env = true
}
2024-01-12 21:52:20 +01:00
template {
data = <<_EOT
PAPERLESS_DBHOST=127.0.0.1
PAPERLESS_DBPORT=5432
2024-03-05 15:00:27 +01:00
PAPERLESS_DBUSER={{ with secret "database/creds/paperless" }}{{ .Data.username }}{{ end }}
PAPERLESS_DBPASS={{ with secret "database/creds/paperless" }}{{ .Data.password }}{{ end }}
2024-01-12 21:52:20 +01:00
_EOT
destination = "secrets/.db.env"
perms = 400
env = true
}
2024-01-05 15:40:45 +01:00
volume_mount {
volume = "data"
destination = "/data"
}
volume_mount {
volume = "input"
destination = "/input"
}
2024-01-24 23:24:36 +01:00
2024-01-05 15:40:45 +01:00
resources {
cpu = 500
memory = 384
memory_max = 512
2024-01-05 15:40:45 +01:00
}
}
}
}