mirror of
https://github.com/casjaysdevdocker/clawlama
synced 2026-06-23 20:01:01 -04:00
2354d8b6e8
Add detailed TODO list for ClawLama project phases including Docker setup, configuration, utility scripts, documentation, and validation criteria.
6.8 KiB
6.8 KiB
ClawLama — TODO.AI.md
Phase 1: Core Container (MVP)
1.1 Dockerfile
- Create multi-stage Dockerfile with
debian:bookworm-slimbase - Stage 1 (builder): Install Node.js LTS via NodeSource
node_lts.xapt repo with GPG key - Stage 1 (builder): Download latest Ollama binary from GitHub releases (
/releases/latest/download/ollama-linux-${TARGETARCH}) - Stage 1 (builder): Install OpenClaw via
npm install -g openclaw@latest - Stage 2 (runtime): Install Node.js LTS runtime (same repo method)
- Stage 2 (runtime): Install
tini,procps,gettext-base,curl - Stage 2 (runtime): Copy Ollama binary from builder
- Stage 2 (runtime): Copy OpenClaw global npm install from builder
- Stage 2 (runtime): Copy
rootfs/overlay - Stage 2 (runtime): Create
clawlamauser/group,/data/ollama,/data/workspacedirs - Stage 2 (runtime):
chmod -R a-w /etcfor hard/etcwrite protection - Stage 2 (runtime): Set ENV defaults (all
CLAWLAMA_*andOLLAMA_*vars) - Stage 2 (runtime):
VOLUME ["/data"],EXPOSE 18789 - Stage 2 (runtime):
HEALTHCHECKpointing to/usr/local/bin/healthcheck.sh - Stage 2 (runtime):
ENTRYPOINT ["tini", "--"]+CMD ["/usr/local/bin/entrypoint.sh"] - Verify no
curl | shorcurl | bashanywhere in Dockerfile
1.2 OpenClaw Config Template
- Create
rootfs/etc/clawlama/openclaw.template.jsonwithenvsubstplaceholders - Include
models.providers.ollamablock withbaseUrl,apiKey: "ollama-local",api: "openai-completions" - Include model entry with
${CLAWLAMA_MODEL},${CLAWLAMA_CONTEXT_WINDOW},${CLAWLAMA_MAX_TOKENS} - Include
agents.defaultswithworkspace: "/data/workspace", concurrency settings - Include
toolsblock:profile: "full",exec.security: "full",exec.ask: "off",elevated.enabled: false - Include
exec.applyPatch.workspaceOnly: true,fs.workspaceOnly: false
1.3 TOOLS.md
- Create
rootfs/etc/clawlama/TOOLS.mdwith git restrictions (no commit, push, reset --hard) - Include filesystem restriction note (no writes to
/etc)
1.4 Entrypoint Script
- Create
rootfs/usr/local/bin/entrypoint.sh(POSIX shell,#!/bin/sh) - Detect architecture (
uname -m→ amd64/arm64) - Detect CPU cores (
nprocor/proc/cpuinfo) and available RAM - Set
OLLAMA_NUM_THREADSif not already set (physical cores) - Detect SIMD capabilities (AVX/AVX2/AVX-512 on amd64, NEON on arm64) and log them
- GPU detection: probe
nvidia-smi, log GPU model + VRAM if found, log CPU-only if not - Print startup banner (arch, cores, RAM, GPU status, model, ports)
- Generate
openclaw.jsonfrom template viaenvsubst→/data/workspace/.openclaw/openclaw.json - Copy
TOOLS.mdto/data/workspace/TOOLS.md(only if not already present — don't overwrite user edits) - Handle multi-model support: parse
CLAWLAMA_MODELScomma-separated list, generate multiple model entries - Handle Telegram integration: if
CLAWLAMA_TELEGRAM_BOT_TOKENset, inject channel config - Start Ollama in background:
ollama serve &, capture PID - Wait for Ollama health: poll
curl -sf http://localhost:11434/with retry loop (max ~60s) - Pull model if not cached:
ollama pull ${CLAWLAMA_MODEL} - Start OpenClaw gateway in foreground:
openclaw gateway --port ${CLAWLAMA_OPENCLAW_PORT} - Trap SIGTERM/SIGINT: forward to Ollama PID, wait for clean shutdown
- Monitor Ollama background process: if it exits unexpectedly, exit entrypoint (trigger Docker restart)
1.5 Health Check Script
- Create
rootfs/usr/local/bin/healthcheck.sh - Check Ollama:
curl -sf http://localhost:11434/or exit 1 - Check OpenClaw:
curl -sf http://localhost:${CLAWLAMA_OPENCLAW_PORT}/or exit 1 - Both pass → exit 0
Phase 2: Build & Compose
2.1 Build Script
- Create
scripts/build.sh - Set up
docker buildxbuilder (create if not exists) - Build + push multi-arch manifest:
docker buildx build --platform linux/amd64,linux/arm64 --push -t docker.io/casjaysdevdocker/clawlama:latest . - Add optional
--loadmode for local testing (single arch) - Add build timestamp label
2.2 docker-compose.yml
- Create
docker-compose.ymlwith service definition - Volume mount:
clawlama-data:/data - Port mapping:
18789:18789 - Restart policy:
unless-stopped - Environment variables with defaults via
.envfile reference - GPU variant: commented-out
deploy.resources.reservations.devicesfor NVIDIA
2.3 Environment Template
- Create
.env.examplewith allCLAWLAMA_*andOLLAMA_*vars with defaults and comments
Phase 3: Utility Scripts
3.1 Backup Script
- Create
scripts/backup.sh - Tar
/datavolume contents to timestamped archive - Support custom output path argument
- Print backup size and location
3.2 Restore Script
- Create
scripts/restore.sh - Restore from tar archive to
/datavolume - Validate archive before extracting
- Warn if container is running
Phase 4: Documentation
4.1 README.md
- Project description and purpose
- Quick start (CPU-only, GPU, custom model examples)
- Environment variable reference table
- Quantized model recommendations by RAM tier (8 GB / 16 GB / 32+ GB)
- GPU setup guide (NVIDIA Container Toolkit prerequisite)
- Multi-model configuration examples
- Telegram integration setup
- Volume and data persistence explanation
- Backup/restore usage
- Troubleshooting section (common issues, logs, health checks)
- Security notes (don't expose gateway publicly, prompt injection surface)
- Portainer/Dockge usage note
- Override config via bind mount
Phase 5: Validation
5.1 Success Criteria Verification
docker pullsucceeds on amd64docker pullsucceeds on arm64docker runbrings up both services with zero manual intervention- Model auto-pulled on first run (CPU)
- OpenClaw responds within 120s of container start
CLAWLAMA_MODELchange + restart pulls new model- Data persists across
docker stop && docker start - Runs on x86_64 Linux VM
- Runs on Apple Silicon Mac (Docker Desktop)
- Runs on Raspberry Pi 5 (arm64)
--gpus allon NVIDIA host → GPU detected in logs- Without
--gpus→ CPU-only, no GPU errors in logs - Image size < 500 MB compressed (excluding models)
5.2 Edge Cases
- First run with no pre-existing
/datavolume - Container restart with existing model cache (should skip pull)
- Invalid
CLAWLAMA_MODELvalue → clear error message - Ollama crash during runtime → container exits, restart policy recovers
- SIGTERM during model pull → clean shutdown
- Low memory host (4 GB) with 7B model → functional but slow