Rebuild openclaw from npm instead of premade image, configure Ollama
- Add Dockerfile using node:22-bookworm-slim + npm install -g openclaw@latest - Update docker-compose.yml: use local build, add OLLAMA_API_KEY=ollama-local, remove legacy OPENCLAW_AGENT_PROVIDER/MODEL/OLLAMA_BASE_URL env vars - Add setup.sh to create openclaw.json with explicit Ollama provider config Key fixes vs previous attempt: - Config file is openclaw.json (not config.json or auth-profiles.json) - models.providers.ollama needs baseUrl with /v1 suffix + explicit model list - OLLAMA_API_KEY env var is required to opt in to Ollama support - reasoning:false on models prevents 400 errors from Ollama
This commit is contained in:
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
# One-time host setup for OpenClaw with Ollama
|
||||
# Run this BEFORE deploying the container.
|
||||
set -e
|
||||
|
||||
echo "=== OpenClaw + Ollama Setup ==="
|
||||
echo ""
|
||||
|
||||
# Ensure config dirs exist
|
||||
mkdir -p /srv/openclaw/config
|
||||
mkdir -p /srv/openclaw/workspace
|
||||
|
||||
# Remove old misconfigured files from previous attempts
|
||||
rm -f /srv/openclaw/config/config.json
|
||||
rm -f /srv/openclaw/config/auth-profiles.json
|
||||
rm -f /srv/openclaw/config/agents/main/agent/auth-profiles.json 2>/dev/null || true
|
||||
|
||||
# Write openclaw.json - the correct config file for provider setup
|
||||
cat > /srv/openclaw/config/openclaw.json << 'EOF'
|
||||
{
|
||||
"models": {
|
||||
"providers": {
|
||||
"ollama": {
|
||||
"baseUrl": "http://ollama:11434/v1",
|
||||
"apiKey": "ollama-local",
|
||||
"api": "openai-completions",
|
||||
"models": [
|
||||
{
|
||||
"id": "gemma3:4b",
|
||||
"name": "Gemma 3 4B",
|
||||
"reasoning": false,
|
||||
"input": ["text"],
|
||||
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||
"contextWindow": 8192,
|
||||
"maxTokens": 8192
|
||||
},
|
||||
{
|
||||
"id": "qwen2.5-coder:7b",
|
||||
"name": "Qwen 2.5 Coder 7B",
|
||||
"reasoning": false,
|
||||
"input": ["text"],
|
||||
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||
"contextWindow": 8192,
|
||||
"maxTokens": 8192
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model": {
|
||||
"primary": "ollama/gemma3:4b"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# Fix ownership so the node user (uid 1000) inside the container can read/write
|
||||
chown -R 1000:1000 /srv/openclaw
|
||||
|
||||
echo "✓ Created /srv/openclaw/config/openclaw.json"
|
||||
echo "✓ Removed old conflicting config files"
|
||||
echo "✓ Fixed permissions (uid 1000)"
|
||||
echo ""
|
||||
echo "=== Next Steps ==="
|
||||
echo ""
|
||||
echo "1. Build the image:"
|
||||
echo " docker compose -f openclaw/docker-compose.yml build"
|
||||
echo ""
|
||||
echo "2. Start the container:"
|
||||
echo " docker compose -f openclaw/docker-compose.yml up -d"
|
||||
echo ""
|
||||
echo "3. Check logs:"
|
||||
echo " docker logs openclaw -f"
|
||||
echo ""
|
||||
echo "4. Verify Ollama connectivity:"
|
||||
echo " docker exec openclaw curl -s http://ollama:11434/v1/models | head -c 200"
|
||||
echo ""
|
||||
echo "5. Redeploy Portainer stack after pushing to git."
|
||||
Reference in New Issue
Block a user