Spaces:
Sleeping
Sleeping
File size: 1,351 Bytes
28db5b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | # Dockerfile — ClauseXplain v5.0
# WHY this exists: HF Spaces Docker builder ignores runtime.txt entirely
# and defaults to python:3.13 where torch<2.5 has no wheels.
# This Dockerfile pins Python 3.10 so torch==2.1.2 installs cleanly.
FROM python:3.10-slim
# System deps: git-lfs (HF model download), libgomp (torch CPU threading),
# libgl1 / libglib2 (pymupdf), build-essential (sentencepiece compile)
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
git-lfs \
libgomp1 \
libgl1 \
libglib2.0-0 \
build-essential \
&& git lfs install \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements first (layer-cache friendly)
COPY requirements.txt .
# Install Python deps — torch 2.1.2 has clean 3.10 wheels on PyPI
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Copy application source
COPY app.py pdf_utils.py inference.py explanation.py utils.py ./
# HF Spaces runs as user 1000 — avoid permission issues
RUN useradd -m -u 1000 appuser \
&& chown -R appuser:appuser /app
USER 1000
EXPOSE 7860
# HF_HOME inside /app so the model cache is writable by user 1000
ENV HF_HOME=/app/.cache/huggingface \
PYTHONUNBUFFERED=1
CMD ["python", "app.py"]
|