# Same pipeline on any machine: Python 3.12 + Tesseract + all dependencies.
FROM python:3.12-slim

# tesseract-ocr includes English; add tesseract-ocr-deu, -fra, ... for other languages.
RUN apt-get update && apt-get install -y --no-install-recommends tesseract-ocr \
    && rm -rf /var/lib/apt/lists/*
COPY --from=ghcr.io/astral-sh/uv:0.13.10 /uv /usr/local/bin/uv

WORKDIR /app
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PROJECT_ENVIRONMENT=/opt/venv PATH="/opt/venv/bin:$PATH" \
    # The container runs as a non-root user with no home folder, so every cache
    # must point at the mounted data volume (the one writable place).
    FASTEMBED_CACHE_PATH=/app/data/models HF_HOME=/app/data/models/hf HOME=/tmp
# Dependencies first (cached layer), then the code.
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-install-project
COPY . .
RUN uv sync --frozen
USER 1000
CMD ["legacy-ingestor", "--help"]
