# Context Vault API image. Small by default (hash embedder, no torch); set
# VAULT_EMBEDDER=sentence-transformer + install the embeddings extra for semantic
# retrieval. The LLM judge activates automatically when ANTHROPIC_API_KEY is set.
FROM python:3.11-slim

RUN pip install --no-cache-dir uv

WORKDIR /app
COPY pyproject.toml README.md ./
COPY context_vault ./context_vault

# core deps + the runtime extras this image needs — still lean (no torch):
#   self-host → Neo4j + psycopg (the durable store that build_vault() opens; CORE no longer ships these)
#   api       → FastAPI + uvicorn (the CMD below imports http_api / runs uvicorn; CORE no longer ships these)
#   mcp       → the MCP server transport
#   audit-encryption → `cryptography`, baked EXPLICITLY so VAULT_AUDIT_ENCRYPTION (ADR-007) works on this
#     published image with NO custom build — set it (postgres-keys) and the encryptor constructs. Since
#     the dep-split moved `mcp` out of CORE, the old transitive chain (mcp → pyjwt[crypto] → cryptography)
#     no longer holds for CORE, so `cryptography` is now pulled IN ITS OWN RIGHT by this extra, not as a
#     side effect.
#   audit-kms → `boto3`, baked EXPLICITLY so the STRONG crypto-shred tier (VAULT_AUDIT_ENCRYPTION=kms,
#     ADR-0017) works on this published image with NO custom build. Without it, an operator who sets
#     `kms` would hit a missing-boto3 ImportError; per ADR-0017 §6 the app now FAILS CLOSED (refuses to
#     boot) on an explicit-but-unsatisfiable encryption request rather than silently serving plaintext —
#     so baking boto3 here is what makes `kms` actually usable on the shipped image. See docs/DEPLOY.md.
RUN uv pip install --system --no-cache '.[self-host,api,mcp,audit-encryption,audit-kms]'

EXPOSE 8000
CMD ["uvicorn", "context_vault.http_api:app", "--host", "0.0.0.0", "--port", "8000"]
