FROM python:3.10-slim WORKDIR /app # Install system dependencies (needed for OpenBLAS and model loading) RUN apt-get update && apt-get install -y \ build-essential \ curl \ libopenblas-dev \ && rm -rf /var/lib/apt/lists/* # Copy requirements first COPY requirements.txt . # Install dependencies # Note: We install the llama-cpp-python wheel DIRECTLY to avoid build timeouts RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir https://huggingface.co/Luigi/llama-cpp-python-wheels-hf-spaces-free-cpu/resolve/main/llama_cpp_python-0.3.22-cp310-cp310-linux_x86_64.whl && \ pip install --no-cache-dir -r requirements.txt # Copy application code COPY app.py . # Expose port (Hugging Face looks for 7860 by default) EXPOSE 7860 ENV PORT=7860 ENV PYTHONUNBUFFERED=1 # Health check (Matches your Flask route) HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 CMD ["python", "app.py"]