feat: Containerize Ollama service in Docker Compose and update the installation script to manage it.

This commit is contained in:
2026-01-17 03:38:27 -03:00
parent dd2c3f666d
commit 3424384ff3
2 changed files with 26 additions and 14 deletions
+17
View File
@@ -30,6 +30,7 @@ services:
- "host.docker.internal:host-gateway"
depends_on:
- db
- ollama
experience:
build:
@@ -45,6 +46,7 @@ services:
env_file: .env
depends_on:
- db
- ollama
whisper:
image: ${WHISPER_IMAGE:-fedirz/faster-whisper-server:latest-cpu}
@@ -63,6 +65,20 @@ services:
count: 1
capabilities: [ gpu ]
ollama:
image: ollama/ollama:latest
ports:
- "11434:11434"
volumes:
- ollama_data:/root/.ollama
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [ gpu ]
e2e:
build:
context: ./e2e
@@ -81,3 +97,4 @@ volumes:
postgres_data:
uploads_data:
whisper_cache:
ollama_data:
+9 -14
View File
@@ -144,28 +144,23 @@ if ! grep -q "DATABASE_URL=" .env || [[ $(grep "DATABASE_URL=" .env | cut -d'='
update_env "JWT_SECRET" "supersecretsecret"
update_env "AI_PROVIDER" "local"
update_env "LOCAL_WHISPER_URL" "http://whisper:8000"
update_env "LOCAL_OLLAMA_URL" "http://host.docker.internal:11434"
update_env "LOCAL_OLLAMA_URL" "http://ollama:11434"
update_env "NEXT_PUBLIC_CMS_API_URL" "http://localhost:3001"
update_env "NEXT_PUBLIC_LMS_API_URL" "http://localhost:3002"
fi
# 5. AI Stack Setup
if ! command -v ollama &> /dev/null; then
curl -fsSL https://ollama.com/install.sh | sh
fi
# 5. AI Stack Setup (Containerized)
echo "⏳ Starting Ollama container..."
docker compose up -d ollama
echo "⏳ Starting Ollama & downloading models..."
# Run ollama in background if not running (simple check)
if ! pgrep ollama &> /dev/null; then
OLLAMA_HOST=0.0.0.0 ollama serve &
sleep 5
fi
echo "⏳ Waiting for Ollama to be ready..."
until docker exec openccb-ollama-1 ollama list &> /dev/null; do sleep 2; done
until curl -s http://localhost:11434/api/tags &> /dev/null; do sleep 2; done
echo "📥 Downloading models..."
if [ "$HAS_NVIDIA" = true ]; then
ollama pull llama3.2:1b
docker exec openccb-ollama-1 ollama pull llama3.2:1b
else
ollama pull phi3:mini
docker exec openccb-ollama-1 ollama pull phi3:mini
fi
# 6. Database Initialization (Integrated db-mgmt.sh)