fix(immich): fix & improve immich

This commit is contained in:
Felix Schröter 2023-04-11 19:30:32 +02:00
parent b8b6127367
commit d64c7db4ae
Signed by: felschr
GPG key ID: 671E39E6744C807D
3 changed files with 39 additions and 14 deletions
services

View file

@ -2,6 +2,7 @@
let
dataDir = "/var/lib/immich";
typesenseDataDir = "/var/lib/typesense/data";
uploadDir = "${dataDir}/upload";
dbuser = "immich";
dbname = "immich";
@ -23,18 +24,23 @@ let
REDIS_PORT = toString config.services.redis.servers.immich.port;
};
# only secrets need to be included, e.g. DB_PASSWORD, JWT_SECRET, MAPBOX_KEY
environmentFiles = [ config.age.secrets.immich-env.path ];
environmentFiles = [
config.age.secrets.immich-env.path
config.age.secrets.immich-typesense-env.path
];
extraOptions = [
"--network=host"
"--add-host=immich-server:127.0.0.1"
"--add-host=immich-microservices:127.0.0.1"
"--add-host=immich-machine-learning:127.0.0.1"
"--add-host=immich-web:127.0.0.1"
"--add-host=typesense:127.0.0.1"
];
};
in {
age.secrets.immich-env.file = ../secrets/immich/.env.age;
age.secrets.immich-db-password.file = ../secrets/immich/db-password.age;
age.secrets.immich-typesense-env.file = ../secrets/immich/typesense/.env.age;
services.postgresql = {
enable = true;
@ -61,7 +67,7 @@ in {
"${ociBackend}-immich-microservices.service"
"${ociBackend}-immich-machine-learning.service"
"${ociBackend}-immich-web.service"
"${ociBackend}-immich-proxy.service"
"${ociBackend}-typesense.service"
];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
@ -69,7 +75,7 @@ in {
LoadCredential = [ "db_password:${dbPasswordFile}" ];
};
script = ''
mkdir -p ${dataDir} ${uploadDir}
mkdir -p ${dataDir} ${uploadDir} ${typesenseDataDir}
echo "Set immich postgres user password"
db_password="$(<"$CREDENTIALS_DIRECTORY/db_password")"
${pkgs.sudo}/bin/sudo -u ${pgSuperUser} ${pkgs.postgresql}/bin/psql postgres \
@ -79,35 +85,41 @@ in {
virtualisation.oci-containers.containers = {
immich-server = immichBase // {
image = "altran1502/immich-server:release";
image = "ghcr.io/immich-app/immich-server:release";
ports = [ "3001:3001" ];
entrypoint = "/bin/sh";
cmd = [ "./start-server.sh" ];
volumes = [ "${uploadDir}:/usr/src/app/upload" ];
dependsOn = [ "typesense" ];
};
immich-microservices = immichBase // {
image = "altran1502/immich-server:release";
image = "ghcr.io/immich-app/immich-server:release";
entrypoint = "/bin/sh";
cmd = [ "./start-microservices.sh" ];
volumes = [ "${uploadDir}:/usr/src/app/upload" ];
dependsOn = [ "typesense" ];
};
# TODO not working atm
/* immich-machine-learning = immichBase // {
image = "altran1502/immich-machine-learning:release";
entrypoint = "/bin/sh";
cmd = [ "./entrypoint.sh" ];
volumes = [ "${uploadDir}:/usr/src/app/upload" ];
};
*/
immich-machine-learning = immichBase // {
image = "ghcr.io/immich-app/immich-machine-learning:release";
volumes = [ "${uploadDir}:/usr/src/app/upload" ];
};
immich-web = immichBase // {
image = "altran1502/immich-web:release";
image = "ghcr.io/immich-app/immich-web:release";
ports = [ "3000:3000" ];
entrypoint = "/bin/sh";
cmd = [ "./entrypoint.sh" ];
};
typesense = {
image = "typesense/typesense:0.24.0";
environment.TYPESENSE_DATA_DIR = "/data";
environmentFiles = [ config.age.secrets.immich-typesense-env.path ];
volumes = [ "${typesenseDataDir}:/data" ];
extraOptions = [ "--network=host" ];
};
};
systemd.services = {