fix(ollama): fix ollama container for CPU vs GPU mode (#1396)

This commit is contained in:
Waleed
2025-09-20 12:08:44 -07:00
committed by GitHub
parent 545e590ce5
commit 1d74ccfeda

View File

@@ -29,8 +29,6 @@ services:
condition: service_completed_successfully condition: service_completed_successfully
realtime: realtime:
condition: service_healthy condition: service_healthy
ollama:
condition: service_healthy
healthcheck: healthcheck:
test: ['CMD', 'wget', '--spider', '--quiet', 'http://127.0.0.1:3000'] test: ['CMD', 'wget', '--spider', '--quiet', 'http://127.0.0.1:3000']
interval: 90s interval: 90s
@@ -99,6 +97,8 @@ services:
# Ollama with GPU support (default) # Ollama with GPU support (default)
ollama: ollama:
profiles:
- gpu
image: ollama/ollama:latest image: ollama/ollama:latest
pull_policy: always pull_policy: always
volumes: volumes:
@@ -120,7 +120,7 @@ services:
count: all count: all
capabilities: [gpu] capabilities: [gpu]
healthcheck: healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:11434/'] test: ['CMD', 'ollama', 'list']
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 5 retries: 5
@@ -144,12 +144,16 @@ services:
- OLLAMA_HOST=0.0.0.0:11434 - OLLAMA_HOST=0.0.0.0:11434
command: 'serve' command: 'serve'
healthcheck: healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:11434/'] test: ['CMD', 'ollama', 'list']
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 5 retries: 5
start_period: 30s start_period: 30s
restart: unless-stopped restart: unless-stopped
networks:
default:
aliases:
- ollama
# Helper container to pull models automatically # Helper container to pull models automatically
model-setup: model-setup:
@@ -160,13 +164,11 @@ services:
- ollama_data:/root/.ollama - ollama_data:/root/.ollama
environment: environment:
- OLLAMA_HOST=ollama:11434 - OLLAMA_HOST=ollama:11434
depends_on: entrypoint: ["/bin/sh", "-lc"]
ollama:
condition: service_healthy
command: > command: >
sh -c " sh -c "
echo 'Waiting for Ollama to be ready...' && echo 'Waiting for Ollama to be ready...' &&
sleep 10 && until ollama list >/dev/null 2>&1; do echo 'Waiting for Ollama...'; sleep 2; done &&
echo 'Pulling gemma3:4b model (recommended starter model)...' && echo 'Pulling gemma3:4b model (recommended starter model)...' &&
ollama pull gemma3:4b && ollama pull gemma3:4b &&
echo 'Model setup complete! You can now use gemma3:4b in Sim.' && echo 'Model setup complete! You can now use gemma3:4b in Sim.' &&