FROM python:3.10-slim # Install libgomp1 for CPU multithreading and other dependencies RUN apt-get update && apt-get install -y \ libgomp1 \ && rm -rf /var/lib/apt/lists/* # Set up user for Hugging Face Spaces (UID 1000) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Copy and install basic requirements COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Install llama-cpp-python from prebuilt CPU wheels for fast, error-free setup RUN pip install --no-cache-dir llama-cpp-python \ --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu # Copy app code COPY --chown=user . . # Hugging Face Spaces uses port 7860 by default EXPOSE 7860 CMD ["python", "app.py"]