# Use an official lightweight Python image FROM python:3.11-slim # System deps for llama.cpp (may require build tools) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ git \ wget \ && rm -rf /var/lib/apt/lists/* # Set workdir WORKDIR /app # Copy requirement first for layer caching COPY requirements.txt ./ # Install Python deps (prefer no cache) RUN pip install --no-cache-dir -r requirements.txt # Copy source COPY . . # Environment defaults (override in HF Space settings) ENV HOST=0.0.0.0 \ PORT=7860 \ LOG_LEVEL=INFO \ LLAMA_MODEL_PATH=./models/meta-llama-3-8b.Q4_K_M.gguf \ LLAMA_REPO_ID=psuplj/Meta-Llama-3-8B-Q4_K_M-GGUF \ LLAMA_FILENAME=meta-llama-3-8b.Q4_K_M.gguf # Expose port EXPOSE 7860 # Healthcheck (simple ping) HEALTHCHECK --interval=30s --timeout=3s --start-period=40s CMD curl -f http://localhost:7860/ || exit 1 # Entrypoint CMD ["python", "app.py"]