update immich

This commit is contained in:
Joakim Repomaa
2024-07-16 10:57:49 +03:00
parent cca6abb196
commit 6cb5322e7b

View File

@@ -6,50 +6,56 @@ let
immich_data_dir = "/mnt/storage/immich"; immich_data_dir = "/mnt/storage/immich";
volumeServices = names: ( volumeServices = names: (
lib.lists.foldl (services: name: lib.lists.foldl
services // { (services: name:
"podman-volume-immich_${name}" = { services // {
path = [ pkgs.podman ]; "podman-volume-immich_${name}" = {
serviceConfig = { path = [ pkgs.podman ];
Type = "oneshot"; serviceConfig = {
RemainAfterExit = true; Type = "oneshot";
RemainAfterExit = true;
};
script = ''
podman volume inspect immich_${name} || podman volume create immich_${name}
'';
partOf = [ "podman-compose-immich-root.target" ];
wantedBy = [ "podman-compose-immich-root.target" ];
}; };
script = '' }
podman volume inspect immich_${name} || podman volume create immich_${name} )
''; { }
partOf = [ "podman-compose-immich-root.target" ]; names
wantedBy = [ "podman-compose-immich-root.target" ];
};
}
) {} names
); );
containerServices = services: ( containerServices = services: (
lib.lists.foldl (acc: { name, volumes ? [], ... }: lib.lists.foldl
let (acc: { name, volumes ? [ ], ... }:
volume_services = map (volume: "podman-volume-immich_${volume}.service") volumes; let
dependent_services = [ "podman-network-immich_default.service" ] ++ volume_services; volume_services = map (volume: "podman-volume-immich_${volume}.service") volumes;
in dependent_services = [ "podman-network-immich_default.service" ] ++ volume_services;
in
acc // { acc // {
"podman-immich_${name}" = { "podman-immich_${name}" = {
serviceConfig = { serviceConfig = {
Restart = lib.mkOverride 500 "always"; Restart = lib.mkOverride 500 "always";
};
after = dependent_services;
requires = dependent_services;
partOf = [
"podman-compose-immich-root.target"
];
wantedBy = [
"podman-compose-immich-root.target"
];
}; };
after = dependent_services; }
requires = dependent_services; )
partOf = [ { }
"podman-compose-immich-root.target" services
];
wantedBy = [
"podman-compose-immich-root.target"
];
};
}
)
{} services
); );
in { in
{
# Containers # Containers
virtualisation.oci-containers.containers = { virtualisation.oci-containers.containers = {
"immich_machine_learning" = { "immich_machine_learning" = {
@@ -67,28 +73,6 @@ in {
]; ];
}; };
"immich_microservices" = {
image = "ghcr.io/immich-app/immich-server:${immich_version}";
environmentFiles = [
"/var/secrets/immich.env"
];
volumes = [
"/etc/localtime:/etc/localtime:ro"
"${immich_data_dir}:/usr/src/app/upload:rw"
"${storage_dir}:${storage_dir}:ro"
];
cmd = [ "start.sh" "microservices" ];
dependsOn = [
"immich_postgres"
"immich_redis"
];
log-driver = "journald";
extraOptions = [
"--network-alias=immich-microservices"
"--network=immich_default"
];
};
"immich_postgres" = { "immich_postgres" = {
image = "registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0"; image = "registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0";
environmentFiles = [ environmentFiles = [
@@ -133,7 +117,6 @@ in {
ports = [ ports = [
"2283:3001/tcp" "2283:3001/tcp"
]; ];
cmd = [ "start.sh" "immich" ];
dependsOn = [ dependsOn = [
"immich_postgres" "immich_postgres"
"immich_redis" "immich_redis"
@@ -151,7 +134,6 @@ in {
{ name = "postgres"; volumes = [ "db_data" ]; } { name = "postgres"; volumes = [ "db_data" ]; }
{ name = "redis"; } { name = "redis"; }
{ name = "server"; } { name = "server"; }
{ name = "microservices"; }
]) // { ]) // {
# Networks # Networks
"podman-network-immich_default" = { "podman-network-immich_default" = {
@@ -191,11 +173,13 @@ in {
fileSystems."${immich_data_dir}" = { fileSystems."${immich_data_dir}" = {
device = "//u407959.your-storagebox.de/backup/immich"; device = "//u407959.your-storagebox.de/backup/immich";
fsType = "cifs"; fsType = "cifs";
options = let options =
# this line prevents hanging on network split let
automount_opts = "x-systemd.automount,auto,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"; # this line prevents hanging on network split
automount_opts = "x-systemd.automount,auto,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s";
in ["${automount_opts},credentials=/var/secrets/smb-storage"]; in
[ "${automount_opts},credentials=/var/secrets/smb-storage" ];
}; };
environment.systemPackages = [ pkgs.cifs-utils ]; environment.systemPackages = [ pkgs.cifs-utils ];