Skip to content

Add Docker deployment and fix KG server OOM#15

Open
justaddcoffee wants to merge 8 commits intomainfrom
fix/kg-disk-storage
Open

Add Docker deployment and fix KG server OOM#15
justaddcoffee wants to merge 8 commits intomainfrom
fix/kg-disk-storage

Conversation

@justaddcoffee
Copy link
Copy Markdown
Contributor

@justaddcoffee justaddcoffee commented Feb 27, 2026

Summary

  • Fix KG server OOM: Switch from in-memory DuckDB to disk-based storage to prevent out-of-memory crashes on gassh
  • Dockerize the app: Add Dockerfile, docker-compose configs (local dev + gassh production), and updated Makefile deploy target
  • app.env replaces .env: Prevents Docker Compose from auto-interpolating bcrypt hashes and other $-containing values

Changes

  • Dockerfile — Python 3.12-slim, Node.js 20, Claude CLI, non-root user
  • docker-compose.yml (local dev) / docker-compose.gassh.yml (production)
  • mcp_config.docker.json — MCP config with container paths
  • app.env.example — environment template (replaces .env.example)
  • Makefile — deploy target now uses ~/agent with Docker Compose; added docker-* targets
  • app.py — bind 0.0.0.0, show=False, load_dotenv("app.env")
  • paperqa_server.pyrebuild_index=False to prevent re-indexing
  • kg_server.py — disk-based DuckDB instead of in-memory

Test plan

  • Docker build succeeds locally
  • Docker build succeeds on gassh
  • Container starts and healthcheck passes (healthy)
  • curl http://localhost:8602/login returns 200
  • Login and send a test query on https://agent.alzassistant.org/
  • Verify KG queries work without OOM

justaddcoffee and others added 2 commits February 27, 2026 17:54
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>
@justaddcoffee justaddcoffee changed the title Fix KG server OOM: use disk-based DuckDB storage Add Docker deployment and fix KG server OOM Mar 13, 2026
justaddcoffee and others added 6 commits March 13, 2026 15:41
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant