From 16557d146de9921bff05ecf90cad889a8053fe4a Mon Sep 17 00:00:00 2001 From: Adrian Gunnar Lauterer Date: Sat, 4 May 2024 17:32:30 +0200 Subject: [PATCH] added webui to ollama --- profiles/ai.nix | 1 + services/ollama-webui.nix | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 services/ollama-webui.nix diff --git a/profiles/ai.nix b/profiles/ai.nix index 5f02c6f..ff4e917 100644 --- a/profiles/ai.nix +++ b/profiles/ai.nix @@ -5,6 +5,7 @@ ./base.nix ../services/podman.nix ../services/ollama.nix + ../services/ollama-webui.nix ../services/whisper.nix ]; diff --git a/services/ollama-webui.nix b/services/ollama-webui.nix new file mode 100644 index 0000000..6d91f02 --- /dev/null +++ b/services/ollama-webui.nix @@ -0,0 +1,27 @@ +{ config, pkgs, lib, ... }: +let + openWebuiImage = "ghcr.io/open-webui/open-webui:main"; +in +{ + virtualisation.oci-containers = { + backend = { + image = openWebuiImage; + cmd = [ "-d" "--network=host" "-v" "open-webui:/app/backend/data" "--name" "open-webui" "--restart" "always" ]; + volumes = [ "open-webui:/app/backend/data" ]; + environment = { + OLLAMA_BASE_URL = "http://127.0.0.1:11434"; + }; + restart = "always"; + }; + }; + + services.nginx.virtualHosts."chat.${config.networking.hostName}.${config.networking.domain}" = { + forceSSL = true; + #useACMEHost = config.networking.domain; #not sure if this will work, unless + locations."/" = { + proxyWebsockets = true; + proxyPass = "http://${config.services.ollama.listenAddress}"; + }; + basicAuthFile = config.sops.secrets."nginx/defaultpass".path; + }; +} \ No newline at end of file