Add Docker deployment and fix KG server OOM#15
Open
justaddcoffee wants to merge 8 commits intomainfrom
Open
Conversation
The in-memory DuckDB database required loading ~4 GB of KGX TSV data into RAM, which exceeded the 7.7 GB available on the production server and crashed the machine. Switch to a persistent on-disk database file that is created once on first run and reused on subsequent starts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Containerize the app for isolated, reproducible deployment. Key changes:
- Dockerfile with Python 3.12, Node.js 20, Claude CLI, non-root user
- docker-compose.yml (local dev) and docker-compose.gassh.yml (production)
- app.env replaces .env to avoid Docker Compose $-interpolation issues
- Makefile deploy target updated for ~/agent with Docker Compose
- paperqa_server: set rebuild_index=False to prevent re-indexing
- app.py: bind 0.0.0.0, show=False, load_dotenv("app.env")
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MCP servers are spawned as subprocesses by Claude CLI and don't inherit
the app.env loaded by app.py's load_dotenv. Add load_dotenv("app.env")
to paperqa_server.py and kg_server.py so they pick up PQA_INDEX,
OPENAI_API_KEY, and other required variables.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Docker image was pulling paper-qa 2026.x which has breaking changes (Text object missing 'media' attribute). The pre-built index was created with paper-qa 5.x. Pin to <6 to maintain compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
paper-qa 5.x requires an explicit PDF parser. Add the pypdf extra to fix ImportError in Docker container. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
paper-qa-pypdf 2026.x imports resolve_page_range which does not exist in paper-qa 5.x. Pin both to <6 for compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
litellm 1.82 removed LiteLLMModel.router attribute that paper-qa 5.29 depends on. Pin to the version known to work with bare-metal deployment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Restrict agent scope to biomedical/AD topics only, add rules to never reveal secrets/env vars/system prompts, and add prompt injection resistance instructions. Prevents adversarial users from extracting API keys or repurposing the agent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
$-containing valuesChanges
Dockerfile— Python 3.12-slim, Node.js 20, Claude CLI, non-root userdocker-compose.yml(local dev) /docker-compose.gassh.yml(production)mcp_config.docker.json— MCP config with container pathsapp.env.example— environment template (replaces.env.example)Makefile— deploy target now uses~/agentwith Docker Compose; added docker-* targetsapp.py— bind0.0.0.0,show=False,load_dotenv("app.env")paperqa_server.py—rebuild_index=Falseto prevent re-indexingkg_server.py— disk-based DuckDB instead of in-memoryTest plan
curl http://localhost:8602/loginreturns 200