Use a file for defining env vars in the service file
There currently isn't a nice way to define env vars outside of overriding the service, I suggest moving the current config from:
Environment="HOME=/var/lib/ollama" "GIN_MODE=release"
to:
EnvironmentFile=/etc/ollama.conf
Current workaround would be
# /etc/systemd/system/ollama.service.d/override.conf
[Service]
EnvironmentFile=/etc/ollama.conf
Environment=
Use case:
I needed to bind it to something else and did all of this if anyone care:
# /etc/ollama.conf
# The host:port to bind to (default "127.0.0.1:11434")
OLLAMA_HOST=0.0.0.0:11434
# A comma separated list of allowed origins.
OLLAMA_ORIGINS=*://localhost,*://192.168.1.40,*://192.168.1.10
# The path to the models directory (default is "~/.ollama/models")
OLLAMA_MODELS=/models/ollama
HOME=/var/lib/ollama
GIN_MODE=release
I've opened an issue upstream about providing a unit file, theirs is currently having the same Environment setup minus the hardening, but it's not even in the repo: https://github.com/ollama/ollama/issues/3516
Edited by Martin Rys