[Unit]
Description=Ollama container service
Wants=network-online.target
After=network-online.target docker.service
Requires=docker.service

[Service]
Type=simple
ExecStartPre=/usr/bin/docker volume create {{ ollama_volume_name }}
ExecStartPre=-/usr/bin/docker rm --force {{ ollama_container_name }}
ExecStart=/usr/bin/docker run \
  --name={{ ollama_container_name }} \
  --publish=0.0.0.0:{{ ollama_port }}:11434 \
  --volume={{ ollama_volume_name }}:{{ ollama_volume_mount }} \
  --gpus {{ ollama_gpu_devices }} \
  --detach=false \
  {{ ollama_docker_image }}
ExecStop=/usr/bin/docker stop {{ ollama_container_name }}
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
