# syntax=docker/dockerfile:1 FROM python:3.11-slim-bookworm ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ HF_HOME=/home/user/.cache/huggingface # Spaces run the container as uid 1000; give it a writable home for the # model cache. RUN apt-get update && apt-get install -y --no-install-recommends \ libgomp1 \ && rm -rf /var/lib/apt/lists/* \ && useradd -m -u 1000 user WORKDIR /app # llama-cpp-python comes from the project's prebuilt CPU wheel index, so # nothing is compiled here (no llama.cpp checkout, no llama-server). COPY requirements.txt . RUN pip install --no-cache-dir \ --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu \ --only-binary llama-cpp-python \ -r requirements.txt COPY app ./app USER user EXPOSE 7860 CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]