privatebin: separate db, cleanup

This commit is contained in:
wizzdom 2025-02-09 19:18:09 +00:00
parent d15d4d1c0a
commit da915caf12
No known key found for this signature in database
GPG key ID: EEB7D796F4B09F07

View file

@ -10,6 +10,9 @@ job "privatebin" {
port "http" { port "http" {
to = 8080 to = 8080
} }
port "db" {
to = 5432
}
} }
service { service {
@ -25,7 +28,7 @@ job "privatebin" {
tags = [ tags = [
"traefik.enable=true", "traefik.enable=true",
"traefik.http.routers.privatebin.rule=Host(`paste.rb.dcu.ie`) || Host(`paste.redbrick.dcu.ie`)", "traefik.http.routers.privatebin.rule=Host(`paste.redbrick.dcu.ie`)",
"traefik.http.routers.privatebin.entrypoints=web,websecure", "traefik.http.routers.privatebin.entrypoints=web,websecure",
"traefik.http.routers.privatebin.tls.certresolver=lets-encrypt", "traefik.http.routers.privatebin.tls.certresolver=lets-encrypt",
] ]
@ -42,15 +45,10 @@ job "privatebin" {
"local/conf.php:/srv/data/conf.php", "local/conf.php:/srv/data/conf.php",
] ]
} }
template { env {
destination = "local/.env" TZ = "Europe/Dublin"
env = true PHP_TZ = "Europe/Dublin"
change_mode = "restart" CONFIG_PATH = "/srv/data/"
data = <<EOH
TZ=Europe/Dublin
PHP_TZ=Europe/Dublin
CONFIG_PATH=/srv/data/
EOH
} }
template { template {
@ -59,7 +57,7 @@ EOH
[main] [main]
name = "Redbrick PasteBin" name = "Redbrick PasteBin"
basepath = "https://paste.rb.dcu.ie/" basepath = "https://paste.redbrick.dcu.ie/"
discussion = true discussion = true
@ -186,12 +184,35 @@ batchsize = 10
class = Database class = Database
[model_options] [model_options]
dsn = "pgsql:host=postgres.service.consul;dbname={{ key "privatebin/db/name" }}" dsn = "pgsql:host=postgres.service.consul;dbname={{ key "privatebin/db/name" }}"
tbl = "privatebin_" ; table prefix tbl = "{{ key "privatebin/db/name" }}" ; table prefix
usr = "{{ key "privatebin/db/user" }}" usr = "{{ key "privatebin/db/user" }}"
pwd = "{{ key "privatebin/db/password" }}" pwd = "{{ key "privatebin/db/password" }}"
opt[12] = true ; PDO::ATTR_PERSISTENT ; use persistent connections - default opt[12] = true ; PDO::ATTR_PERSISTENT ; use persistent connections - default
EOH EOH
} }
} }
task "db" {
driver = "docker"
config {
image = "postgres:17-alpine"
ports = ["db"]
volumes = [
"/storage/nomad/${NOMAD_JOB_NAME}/${NOMAD_TASK_NAME}:/var/lib/postgresql/data",
]
}
template {
data = <<EOH
POSTGRES_PASSWORD={{ key "privatebin/db/password" }}
POSTGRES_USER={{ key "privatebin/db/user" }}
POSTGRES_NAME={{ key "privatebin/db/name" }}
EOH
destination = "local/db.env"
env = true
}
}
} }
} }