Skip to content

Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.

Add Docker packaging; make local model cache relocatable

anirudhkumar-nanonets71a544ca9702
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..e2eb8f14
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,16 @@
+node_modules
+dist
+.git
+.env
+.env.*
+.context-graph
+*.db
+*.db-shm
+*.db-wal
+*.log
+*.png
+*.html
+sample-docs
+test
+examples
+.mcp.json
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..6ef9a87b
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,35 @@
+# Context Graph — team-brain web UI in one container.
+#
+# docker compose up → http://localhost:4680
+#
+# The graph persists to the /data volume as a single SQLite file. The server
+# binds 0.0.0.0 inside the container and requires the access token printed in
+# the container logs on first start (or set CONTEXT_GRAPH_WEB_TOKEN).
+
+FROM node:22-slim AS build
+WORKDIR /app
+COPY package.json package-lock.json ./
+# `prepare` would try to compile before src is copied; native-module install
+# scripts (better-sqlite3) must still run, so drop only the prepare hook.
+RUN npm pkg delete scripts.prepare && npm ci
+COPY tsconfig.json ./
+COPY src ./src
+RUN npx tsc -p tsconfig.json \
+ && mkdir -p dist/web && cp src/web/ui.html dist/web/ui.html \
+ && npm prune --omit=dev
+
+FROM node:22-slim
+WORKDIR /app
+ENV NODE_ENV=production \
+ HOST=0.0.0.0 \
+ PORT=4680 \
+ CONTEXT_GRAPH_DB=/data/graph.db \
+ CONTEXT_GRAPH_MODEL_CACHE=/data/.model-cache
+COPY --from=build /app/node_modules ./node_modules
+COPY --from=build /app/dist ./dist
+COPY package.json ./
+RUN mkdir -p /data && chown node:node /data
+USER node
+EXPOSE 4680
+VOLUME /data
+CMD ["node", "dist/web.js"]
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..10e185fa
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,23 @@
+# Context Graph — one shared team-brain server.
+#
+# docker compose up -d
+# docker compose logs | grep token # grab the access/share link
+#
+# The graph lives in ./data as a single SQLite file. Put documents you want to
+# ingest into ./docs and type /docs in the UI's "Ingest a folder" box.
+services:
+ context-graph:
+ build: .
+ ports:
+ - "4680:4680"
+ volumes:
+ - ./data:/data
+ - ./docs:/docs:ro
+ environment:
+ # Optional: cloud extraction + written answers. Without it the graph and
+ # retrieval still work; extraction needs this key or a reachable Ollama.
+ OPENROUTER_API_KEY: ${OPENROUTER_API_KEY:-}
+ # Optional: pin the access token; otherwise one is generated per start
+ # and printed in the logs.
+ CONTEXT_GRAPH_WEB_TOKEN: ${CONTEXT_GRAPH_WEB_TOKEN:-}
+ restart: unless-stopped
diff --git a/src/ai/local.ts b/src/ai/local.ts
index 81d0d95f..ba5de569 100644
--- a/src/ai/local.ts
+++ b/src/ai/local.ts
@@ -47,6 +47,10 @@ export class LocalEmbedder implements Embedder {
this.pipe = import("@huggingface/transformers").then(({ pipeline, env }) => {
// Keep console noise down; models still download+cache on first use.
env.allowRemoteModels = true;
+ // Default cache lives inside node_modules, which is read-only in
+ // containers / global installs — allow relocating it.
+ const cacheDir = process.env.CONTEXT_GRAPH_MODEL_CACHE;
+ if (cacheDir) env.cacheDir = cacheDir;
return pipeline("feature-extraction", this.model) as unknown as Promise<FeaturePipeline>;
});
}