more webapp stuff

This commit is contained in:
atagen 2024-05-02 13:55:15 +10:00
parent 9bc61077d5
commit 533f88f4cd
4 changed files with 34 additions and 15 deletions

View file

@ -21,7 +21,8 @@
localWebApps = {
stable-diffusion = {
name = "ComfyUI (Stable Diffusion)";
name = "Stable Diffusion (ComfyUI)";
genericName = "Stable Diffusion";
icon = ./icons/comfyui.png;
id = 5;
port = 7860;
@ -32,7 +33,8 @@
};
openwebui = rec {
name = "OpenWebUI (Ollama)";
name = "Ollama (OpenWebUI)";
genericName = "Ollama";
icon = ./icons/openwebui.png;
id = 6;
port = 3021;
@ -40,9 +42,17 @@
docker = lib.getExe pkgs.docker;
in {
Type = "exec";
ExecStartPre = "-${docker} create -e PORT=${builtins.toString port} --network host --gpus all -v ollama:/root/.ollama -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:ollama";
ExecStart = "${docker} start open-webui";
ExecStop = "${docker} stop open-webui";
ExecStartPre = "${pkgs.writeShellScript "openwebui-check" ''
set -euo pipefail
echo Checking for container existence..
if [[ $(${docker} inspect openwebui &> /dev/null; printf $?) -ne 0 ]]; then
echo Not found. Creating OpenWebUI/Ollama container..
${docker} create -e PORT=${builtins.toString port} --network host --gpus all -v ollama:/root/.ollama -v open-webui:/app/backend/data --name openwebui --restart always ghcr.io/open-webui/open-webui:ollama
fi
echo Check complete.
''}";
ExecStart = "${docker} start -a openwebui";
ExecStop = "${docker} stop openwebui";
};
};
};