From dc250f5eba75c617eeb4377450b34b22610a7315 Mon Sep 17 00:00:00 2001 From: atlas Date: Wed, 1 Jul 2026 19:28:14 +0000 Subject: [PATCH] add Deployment --- Deployment.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Deployment.md diff --git a/Deployment.md b/Deployment.md new file mode 100644 index 0000000..5e4c417 --- /dev/null +++ b/Deployment.md @@ -0,0 +1,56 @@ +# Deployment + +SecondBrain is one file + one SQLite db. It runs anywhere Python and Ollama reach. + +## 1. Local (any OS) +```bash +ollama pull nomic-embed-text # embedding backend +bash deploy/install.sh # venv + deps + schema +. .venv/bin/activate +python3 brain.py ingest-files +python3 brain.py embed +python3 brain.py recall "q" --hybrid +``` + +## 2. Continuous refresh (systemd timer, Linux) +Set your sources in `.env`: +``` +SB_FILE_DIRS=/home/me/notes:/home/me/code +SB_TRANSCRIPTS=/home/me/.claude/projects +SB_EVENTS_DB=/home/me/events.db +SB_EMBED_LIMIT=6000 +``` +Then: +```bash +sudo cp deploy/secondbrain-refresh.* /etc/systemd/system/ +# edit WorkingDirectory/EnvironmentFile in the .service to match your install +sudo systemctl enable --now secondbrain-refresh.timer +``` +`refresh.sh` is locked (flock), niced, and idempotent — safe to run every 15 min. + +## 3. Docker +```bash +docker build -t secondbrain -f deploy/Dockerfile . +docker run --rm -v sbdata:/data \ + -e OLLAMA_URL=http://host.docker.internal:11434 \ + secondbrain recall "q" --hybrid +``` +The db lives on the `/data` volume and survives rebuilds. + +## 4. GPU offload (keep a laptop's brain current from a desktop GPU) +Embeddings are the only heavy step. Point `OLLAMA_URL` at any reachable Ollama — +a desktop/GPU box on your LAN or tailnet: +``` +OLLAMA_URL=http://100.x.y.z:11434 +``` +SecondBrain embeds *there* and stores the vectors *locally*. No extra infrastructure, +no tunnels — if you can curl the Ollama endpoint, it works. When the GPU box is +asleep, embedding simply pauses; lexical (FTS5) recall keeps working meanwhile. + +## Moving / backing up a brain +It's one file. `cp brain.db elsewhere`. That's the whole backup and migration story. + +## Sizing +- ~768 floats × 4 bytes ≈ 3 KB of vector per chunk, plus the text. +- Embedding rate depends on your Ollama backend (CPU ~5–20/s, small GPU ~20–60/s). +- `embed --limit N` bounds a run; the rest continues next run.