From 71b4140067452cb45e3cbc7e981005c38fcd90be Mon Sep 17 00:00:00 2001 From: Rounak Datta Date: Fri, 19 Jan 2024 20:20:49 +0530 Subject: [PATCH] Add new postgres container for immich --- .../templates/immich.nomad.j2 | 3 ++ .../templates/postgresql.nomad.j2 | 37 ++++++++++++++++++- .../templates/nomad.hcl.j2 | 4 ++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/roles/launch-nomad-jobs/templates/immich.nomad.j2 b/roles/launch-nomad-jobs/templates/immich.nomad.j2 index 590a927..c653fe7 100644 --- a/roles/launch-nomad-jobs/templates/immich.nomad.j2 +++ b/roles/launch-nomad-jobs/templates/immich.nomad.j2 @@ -63,6 +63,7 @@ job "immich_job" { env = { NODE_ENV = "production" DB_HOSTNAME = "{{ Hostname }}" + DB_PORT = "5433" DB_USERNAME = "{{ ImmichUsername }}" DB_PASSWORD = "{{ ImmichPassword }}" DB_DATABASE_NAME = "{{ ImmichDatabase }}" @@ -100,6 +101,7 @@ job "immich_job" { env = { NODE_ENV = "production" DB_HOSTNAME = "{{ Hostname }}" + DB_PORT = "5433" DB_USERNAME = "{{ ImmichUsername }}" DB_PASSWORD = "{{ ImmichPassword }}" DB_DATABASE_NAME = "{{ ImmichDatabase }}" @@ -136,6 +138,7 @@ job "immich_job" { env = { NODE_ENV = "production" DB_HOSTNAME = "{{ Hostname }}" + DB_PORT = "5433" DB_USERNAME = "{{ ImmichUsername }}" DB_PASSWORD = "{{ ImmichPassword }}" DB_DATABASE_NAME = "{{ ImmichDatabase }}" diff --git a/roles/launch-nomad-jobs/templates/postgresql.nomad.j2 b/roles/launch-nomad-jobs/templates/postgresql.nomad.j2 index a6728e6..c926270 100644 --- a/roles/launch-nomad-jobs/templates/postgresql.nomad.j2 +++ b/roles/launch-nomad-jobs/templates/postgresql.nomad.j2 @@ -11,6 +11,12 @@ job "postgresql_job" { to = 5432 host_network = "tailscale" } + + port "immich_postgresql_port" { + static = 5433 + to = 5433 + host_network = "tailscale" + } } volume "postgresql_volume" { @@ -19,6 +25,12 @@ job "postgresql_job" { read_only = false } + volume "immich_postgresql_volume" { + type = "host" + source = "immich_postgresql_hdd_volume" + read_only = false + } + restart { attempts = 2 interval = "10m" @@ -41,12 +53,33 @@ job "postgresql_job" { } config { - image = "rounakdatta/pgvecto-rs:pg14-v0.1.11" - + image = "rounakdatta/postgres:14.5" ports = ["postgresql_port"] } } + + task "immich_postgresql_server" { + driver = "docker" + + env = { + POSTGRES_USER = "{{ DatabaseRootUser }}" + POSTGRES_PASSWORD = "{{ DatabaseRootPassword }}" + } + + volume_mount { + volume = "immich_postgresql_volume" + destination = "/var/lib/postgresql/data" + read_only = false + } + + config { + image = "rounakdatta/postgres:14.5" + ports = ["immich_postgresql_port"] + + } + } + } } diff --git a/roles/launch-orchestrators/templates/nomad.hcl.j2 b/roles/launch-orchestrators/templates/nomad.hcl.j2 index 70acc63..e17038b 100644 --- a/roles/launch-orchestrators/templates/nomad.hcl.j2 +++ b/roles/launch-orchestrators/templates/nomad.hcl.j2 @@ -139,6 +139,10 @@ client { path = "{{ hdd_mount_path }}/homelab/postgresql" } + host_volume "immich_postgresql_hdd_volume" { + path = "{{ hdd_mount_path }}/homelab/immich_postgresql" + } + host_volume "monica_hdd_volume" { path = "{{ hdd_mount_path }}/homelab/monica" }