ollama: use docker

This commit is contained in:
Giulio De Pasquale 2024-05-14 17:09:45 +01:00
parent 8ab9cd67f7
commit 404a53135c

View File

@ -11,18 +11,18 @@ in
{ {
environment = { environment = {
systemPackages = [ ollamaPkg pkgs.aichat ]; systemPackages = [ ollamaPkg pkgs.aichat ];
variables = { # variables = {
OLLAMA_ORIGINS = "*"; # OLLAMA_ORIGINS = "*";
}; # };
}; };
services.ollama = { # services.ollama = {
inherit listenAddress; # inherit listenAddress;
enable = true; # enable = true;
acceleration = "cuda"; # acceleration = "cuda";
package = ollamaPkg; # package = ollamaPkg;
}; # };
architect.vhost.${frontendDomain} = { architect.vhost.${frontendDomain} = {
dnsInterfaces = [ "tailscale" ]; dnsInterfaces = [ "tailscale" ];
@ -49,13 +49,32 @@ in
extraConfig = '' extraConfig = ''
proxy_buffering off; proxy_buffering off;
proxy_read_timeout 600s; proxy_read_timeout 600s;
proxy_set_header Host localhost:11434; proxy_set_header Host localhost:${toString ollamaPort};
''; '';
}; };
}; };
virtualisation.oci-containers = { virtualisation.oci-containers = {
containers = { containers = {
ollama = {
image = "ollama/ollama:latest";
autoStart = true;
extraOptions = [
"--pull=always"
"--gpus=all"
];
environment = {
OLLAMA_ORIGINS = "*";
};
volumes = [
"/ollama:/root/.ollama"
];
ports = [
"${listenAddress}:${toString ollamaPort}"
"172.17.0.1:${toString ollamaPort}:${toString ollamaPort}"
];
};
ollama-webui = { ollama-webui = {
image = "ghcr.io/open-webui/open-webui:main"; image = "ghcr.io/open-webui/open-webui:main";
autoStart = true; autoStart = true;