FROM python:3.11-slim # Install minimal build tools RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ cmake \ pkg-config \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python deps COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Build the LATEST llama-cpp-python from source. # We disable BLAS (OpenBLAS/OpenCL) to significantly speed up compilation # and avoid the 20-minute Hugging Face build timeout. # Standard CPU optimization is still very fast for a 4B model. RUN CMAKE_ARGS="-DGGML_BLAS=OFF" pip install --no-cache-dir llama-cpp-python COPY . . EXPOSE 7860 CMD ["python", "-c", "import uvicorn; uvicorn.run('app:app', host='0.0.0.0', port=7860)"]