FROM python:3.10-slim # 1. Install system dependencies for PyMuPDF and basic building RUN apt-get update && apt-get install -y \ build-essential \ libgl1 \ libglib2.0-0 \ wget \ && rm -rf /var/lib/apt/lists/* WORKDIR /code # 2. Install llama-cpp-python using a PRE-COMPILED wheel optimized for HF Spaces # This is a direct download link that skips the 'Building wheel' process entirely RUN pip install --no-cache-dir \ https://huggingface.co/Luigi/llama-cpp-python-wheels-hf-spaces-free-cpu/resolve/main/llama_cpp_python-0.3.16-cp310-cp310-linux_x86_64.whl # 3. Copy requirements and install (Ensure llama-cpp-python is NOT in your requirements.txt) COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir -r /code/requirements.txt COPY . . # 4. Permissions and Cache for the model RUN mkdir -p /code/cache && chmod 777 /code/cache ENV HF_HOME=/code/cache ENV TRANSFORMERS_CACHE=/code/cache # Start the application CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]