FROM python:3.11-slim # Build tools only matter if pip has to compile llama-cpp-python from source RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential cmake git \ && rm -rf /var/lib/apt/lists/* # HF Spaces run containers as uid 1000 RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ HF_HOME=/home/user/hf-cache \ PYTHONUNBUFFERED=1 WORKDIR /home/user/app RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir --upgrade huggingface_hub datasets && \ pip install --no-cache-dir llama-cpp-python \ --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu COPY --chown=user app.py . EXPOSE 7860 CMD ["python", "app.py"]