# Moonley schema-v5 backend — Hugging Face Space (Docker SDK), CPU-only. FROM python:3.11-slim ENV PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ HF_HOME=/tmp/hf \ SENTENCE_TRANSFORMERS_HOME=/tmp/hf/sentence-transformers \ TRANSFORMERS_CACHE=/tmp/hf/transformers \ MOONLEY_DATA=/tmp/moonley_release \ MOONLEY_STATUTE="/app/statute corpus" \ MOONLEY_STATUTE_CHROMA=/tmp/moonley_statutes \ MOONLEY_QWEN_MODEL=/app/qwen_model \ MOONLEY_QWEN_DTYPE=bfloat16 \ MOONLEY_WARM_QUERY_MODEL=1 \ MOONLEY_DEEP=never \ MOONLEY_SKIM=0 \ MOONLEY_HELD_ARM=0 \ MOONLEY_CITECTX=0 \ MOONLEY_BUDGET_S=20 \ MOONLEY_DEVICE=cpu \ MOONLEY_LOG_DIR=/tmp/moonley_logs \ MOONLEY_PDF_CACHE=/tmp/pdf_cache \ MOONLEY_KEYWORD=0 \ OMP_NUM_THREADS=8 \ TOKENIZERS_PARALLELISM=false WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends build-essential fonts-dejavu-core tesseract-ocr \ && rm -rf /var/lib/apt/lists/* # CPU torch in its own layer (heavy, rarely changes), then the serving deps. RUN pip install torch --index-url https://download.pytorch.org/whl/cpu COPY phase1/deploy/requirements.txt ./req.txt RUN pip install -r req.txt huggingface_hub # Fetch private artifacts at runtime so neither snapshot is embedded in this # public image. Revisions are immutable and every expected entrypoint is checked. ENV MOONLEY_RELEASE_REPO=vg15o2/themis-indian-kanoon-qwen-v1 \ MOONLEY_RELEASE_REVISION=12f58201987cc8ec7697010754ab75765c5f5a24 \ MOONLEY_STATUTE_REPO=vg15o2/themis-statutes-v1 \ MOONLEY_STATUTE_REVISION=ebf66528e417358a09903d95f6718ccfeb94a426 ARG QWEN_MODEL_REVISION=5cf2132abc99cad020ac570b19d031efec650f2b RUN python -c "import os; from huggingface_hub import snapshot_download; snapshot_download(repo_id='Qwen/Qwen3-Embedding-4B', repo_type='model', revision=os.environ['QWEN_MODEL_REVISION'], local_dir='/app/qwen_model')" # Keep private release pointers after the large, cacheable model layer. Updating # a small template release must not force the Qwen model to download again. ENV MOONLEY_DRAFTING_TEMPLATE_REPO=vg15o2/themis-drafting-templates-v1 \ MOONLEY_DRAFTING_TEMPLATE_REVISION=2b036d4bef7ebe7a3b3bb8d0a094d7fefdd8c4d2 COPY . . # HF runs the container as a non-root user; only /tmp is writable. RUN mkdir -p /tmp/hf /tmp/moonley_logs /tmp/pdf_cache && chmod -R 777 /tmp/hf /tmp/moonley_logs /tmp/pdf_cache EXPOSE 7860 CMD ["python", "phase1/scripts/start_private_space.py"]