add Deployment
parent
d2a30db792
commit
dc250f5eba
1 changed files with 56 additions and 0 deletions
56
Deployment.md
Normal file
56
Deployment.md
Normal file
|
|
@ -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 <dir>
|
||||||
|
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.
|
||||||
Loading…
Reference in a new issue