Major_Project / Dockerfile
riyasuryawanshi746's picture
Uploaded the explainability improvements 11th may,lime, gemini, n more
28db5b3 verified
# 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"]