feat: Containerize Ollama service in Docker Compose and update the installation script to manage it.
This commit is contained in:
@@ -30,6 +30,7 @@ services:
|
|||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
- ollama
|
||||||
|
|
||||||
experience:
|
experience:
|
||||||
build:
|
build:
|
||||||
@@ -45,6 +46,7 @@ services:
|
|||||||
env_file: .env
|
env_file: .env
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
- ollama
|
||||||
|
|
||||||
whisper:
|
whisper:
|
||||||
image: ${WHISPER_IMAGE:-fedirz/faster-whisper-server:latest-cpu}
|
image: ${WHISPER_IMAGE:-fedirz/faster-whisper-server:latest-cpu}
|
||||||
@@ -63,6 +65,20 @@ services:
|
|||||||
count: 1
|
count: 1
|
||||||
capabilities: [ gpu ]
|
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:
|
e2e:
|
||||||
build:
|
build:
|
||||||
context: ./e2e
|
context: ./e2e
|
||||||
@@ -81,3 +97,4 @@ volumes:
|
|||||||
postgres_data:
|
postgres_data:
|
||||||
uploads_data:
|
uploads_data:
|
||||||
whisper_cache:
|
whisper_cache:
|
||||||
|
ollama_data:
|
||||||
|
|||||||
+9
-14
@@ -144,28 +144,23 @@ if ! grep -q "DATABASE_URL=" .env || [[ $(grep "DATABASE_URL=" .env | cut -d'='
|
|||||||
update_env "JWT_SECRET" "supersecretsecret"
|
update_env "JWT_SECRET" "supersecretsecret"
|
||||||
update_env "AI_PROVIDER" "local"
|
update_env "AI_PROVIDER" "local"
|
||||||
update_env "LOCAL_WHISPER_URL" "http://whisper:8000"
|
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_CMS_API_URL" "http://localhost:3001"
|
||||||
update_env "NEXT_PUBLIC_LMS_API_URL" "http://localhost:3002"
|
update_env "NEXT_PUBLIC_LMS_API_URL" "http://localhost:3002"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5. AI Stack Setup
|
# 5. AI Stack Setup (Containerized)
|
||||||
if ! command -v ollama &> /dev/null; then
|
echo "⏳ Starting Ollama container..."
|
||||||
curl -fsSL https://ollama.com/install.sh | sh
|
docker compose up -d ollama
|
||||||
fi
|
|
||||||
|
|
||||||
echo "⏳ Starting Ollama & downloading models..."
|
echo "⏳ Waiting for Ollama to be ready..."
|
||||||
# Run ollama in background if not running (simple check)
|
until docker exec openccb-ollama-1 ollama list &> /dev/null; do sleep 2; done
|
||||||
if ! pgrep ollama &> /dev/null; then
|
|
||||||
OLLAMA_HOST=0.0.0.0 ollama serve &
|
|
||||||
sleep 5
|
|
||||||
fi
|
|
||||||
|
|
||||||
until curl -s http://localhost:11434/api/tags &> /dev/null; do sleep 2; done
|
echo "📥 Downloading models..."
|
||||||
if [ "$HAS_NVIDIA" = true ]; then
|
if [ "$HAS_NVIDIA" = true ]; then
|
||||||
ollama pull llama3.2:1b
|
docker exec openccb-ollama-1 ollama pull llama3.2:1b
|
||||||
else
|
else
|
||||||
ollama pull phi3:mini
|
docker exec openccb-ollama-1 ollama pull phi3:mini
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 6. Database Initialization (Integrated db-mgmt.sh)
|
# 6. Database Initialization (Integrated db-mgmt.sh)
|
||||||
|
|||||||
Reference in New Issue
Block a user