Switch from arion to manual

This commit is contained in:
niten 2024-05-21 10:56:23 -07:00
parent 931231a450
commit 975316a114
1 changed files with 33 additions and 20 deletions

View File

@ -1,7 +1,27 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.services.immichMlContainer;
let
cfg = config.services.immichMlContainer;
immichMlConfigYaml = pkgs.writeJSON "immich-ml-compose.yml" {
version = "3.4";
networks.default.name = "immich-ml";
volumes = { };
services.immich-ml = {
image =
"ghcr.io/immich-app/immich-machine-learning:${cfg.immich-version}-cuda";
deploy.resources.reservations.devices = [{
driver = "nvidia";
count = 1;
capabilities = [ "gpu" ];
}];
ports = [ "${cfg.port}:3003" ];
restart = "always";
volumes = [ "${cfg.state-directory}:/cache" ];
};
};
in {
options.services.immichMlContainer = with types; {
enable = mkEnableOption "Enable machine learning container.";
@ -31,27 +51,20 @@ in {
};
config = mkIf cfg.enable {
systemd.tmpfiles.rules = [ "d ${cfg.state-directory} 0750 root root - -" ];
systemd = {
services.immich-machine-learning = {
after = [ "network-online.target" ];
before = [ "nginx.service" ];
path = with pkgs; [ podman-compose ];
serviceConfig = {
ExecStart = pkgs.writeShellScript "immich-machine-learning" ''
podman-compose -f ${immichMlConfigYaml}
'';
};
};
virtualisation.arion.projects.immich-ml.settings = let
image = { ... }: {
project.name = "immich-ml";
services.immich-ml = {
image.rawConfig.deploy.resources.reservations.devices = [{
driver = "nvidia";
count = 1;
capabilities = [ "gpu" ];
}];
service = {
image =
"ghcr.io/immich-app/immich-machine-learning:${cfg.immich-version}-cuda";
restart = "always";
ports = [ "${toString cfg.port}:3003" ];
volumes = [ "${cfg.state-directory}:/cache" ];
tmpfiles.rules = [ "d ${cfg.state-directory} 0750 root root - -" ];
};
};
};
in { imports = [ image ]; };
services.nginx = {
enable = true;