# lore-server container image.
# Build from the repo root:  docker build -f deploy/Dockerfile -t lore .
# Normally used via deploy/compose.yaml (server + Ollama + volumes).
FROM python:3.11-slim

WORKDIR /app

# Install the package (hatchling build includes src/lore + built-in task
# templates). Wheels exist for all heavy deps (chromadb, pymupdf,
# tree-sitter) so no build toolchain is needed in the image.
COPY pyproject.toml README.md ./
COPY src ./src
RUN pip install --no-cache-dir .

# All state (config, SQLite, vector store, logs) lives under the volume.
ENV LORE_HOME=/data/lore \
    LORE_HOST=0.0.0.0 \
    LORE_PORT=5673
VOLUME /data
EXPOSE 5673

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s CMD \
    python -c "import urllib.request as u; u.urlopen('http://127.0.0.1:5673/health', timeout=3)" \
    || exit 1

CMD ["python", "-m", "lore.server"]
