From 355bd0593dc2b0d5268a93e517397e3550d04597 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Sun, 7 Sep 2025 03:09:49 +0200 Subject: [PATCH] Add immich --- modules/podman.nix | 72 +++++++++++++++++++++++++++++++++++++++++++++ modules/traefik.nix | 17 +++++++++++ 2 files changed, 89 insertions(+) diff --git a/modules/podman.nix b/modules/podman.nix index 6aeff9e..ee1ce9b 100644 --- a/modules/podman.nix +++ b/modules/podman.nix @@ -42,6 +42,78 @@ autoStart = true; }; + + # Immich photo and video backup system + containers.immich = { + image = "ghcr.io/imagegenius/immich:latest"; + + volumes = [ + "/home/yanlin/deploy/data/immich/config:/config" + "/mnt/storage/appbulk/immich:/photos" + "/mnt/storage/Media/DCIM:/libraries" + ]; + + environment = { + PUID = "1000"; + PGID = "100"; + TZ = "Europe/Copenhagen"; + DB_HOSTNAME = "immich-db"; + DB_USERNAME = "postgres"; + DB_PASSWORD = "postgres"; + DB_DATABASE_NAME = "postgres"; + DB_PORT = "5432"; + REDIS_HOSTNAME = "immich-redis"; + REDIS_PORT = "6379"; + MACHINE_LEARNING_HOST = "0.0.0.0"; + MACHINE_LEARNING_PORT = "3003"; + MACHINE_LEARNING_WORKERS = "1"; + MACHINE_LEARNING_WORKER_TIMEOUT = "120"; + }; + + ports = [ + "5000:8080" + ]; + + extraOptions = [ + "--network=podman" + "--device=/dev/dri:/dev/dri" # Hardware acceleration + ]; + + dependsOn = [ "immich-db" "immich-redis" ]; + autoStart = true; + }; + + # PostgreSQL database for Immich with vector extension + containers.immich-db = { + image = "docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0"; + + volumes = [ + "/home/yanlin/deploy/data/immich/db:/var/lib/postgresql/data" + ]; + + environment = { + POSTGRES_PASSWORD = "postgres"; + POSTGRES_USER = "postgres"; + POSTGRES_DB = "postgres"; + }; + + extraOptions = [ + "--network=podman" + ]; + + autoStart = true; + }; + + # Redis cache for Immich + containers.immich-redis = { + image = "docker.io/redis:7.2-alpine"; + + extraOptions = [ + "--network=podman" + ]; + + autoStart = true; + }; }; }; } \ No newline at end of file diff --git a/modules/traefik.nix b/modules/traefik.nix index b20296b..2112e63 100644 --- a/modules/traefik.nix +++ b/modules/traefik.nix @@ -71,6 +71,16 @@ }]; }; }; + immich = { + rule = "Host(`photo.hs.yanlincs.com`)"; + service = "immich"; + tls = { + certResolver = "cloudflare"; + domains = [{ + main = "*.hs.yanlincs.com"; + }]; + }; + }; }; services = { homeassistant = { @@ -80,6 +90,13 @@ }]; }; }; + immich = { + loadBalancer = { + servers = [{ + url = "http://localhost:5000"; + }]; + }; + }; }; }; };