# quantcrypt ships manylinux_x86_64 wheels only — no linux/arm64 binary.
# Pin to amd64; Rosetta runs it transparently on Apple Silicon.
FROM --platform=linux/amd64 python:3.13-slim

COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

WORKDIR /app

COPY pyproject.toml README.md ./
COPY src ./src

RUN uv pip install --system --no-cache ".[websockets]"

# All HyperMind state (env file, DB, populations, sims) lives here.
# Mount a volume or bind-mount to persist across restarts.
ENV HYPERMIND_HOME=/data
RUN mkdir -p /data

VOLUME ["/data"]

# TCP MCP (JSON-RPC 2.0) on 8484, optional SSE dashboard on 8766
EXPOSE 8484 8766

# Print usage on start so operators know exactly how to configure.
# Pass LLM keys via -e or --env-file; mount /data for persistence.
#
# Quick start:
#   docker run -d \
#     -e OPENAI_API_KEY=sk-... \
#     -v hm-data:/data \
#     -p 8484:8484 -p 8766:8766 \
#     openworkbench/hypermind
#
# With env file (recommended):
#   docker run -d \
#     --env-file .env \
#     -v hm-data:/data \
#     -p 8484:8484 -p 8766:8766 \
#     openworkbench/hypermind
#
# .env file keys:
#   OPENAI_API_KEY=sk-...
#   ANTHROPIC_API_KEY=sk-ant-...   # or use Anthropic
#   OPENAI_BASE_URL=http://...     # local model (Ollama etc.)
#   HYPERMIND_LLM_MODEL=gpt-4o
#   RELATA_URL=http://relata:9090  # optional durable ledger
CMD ["hmctl", "mcp", "serve"]
