# ---- Builder stage ---- FROM debian:bookworm-slim AS builder RUN apt-get update && apt-get install -y \ build-essential \ cmake \ git \ curl \ libcurl4-openssl-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /build # Pin a known-good release that supports --jinja. # Verify current tags at https://github.com/ggml-org/llama.cpp/releases before bumping. RUN git clone --depth 1 --branch b10107 https://github.com/ggml-org/llama.cpp.git WORKDIR /build/llama.cpp # Build with CPU-only, no CUDA, statically linked (no .so files to manage) RUN cmake -B build \ -DGGML_NATIVE=ON \ -DGGML_CUDA=OFF \ -DLLAMA_CURL=ON \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE=Release \ && cmake --build build --config Release -j2 --target llama-server # ---- Runtime stage ---- FROM debian:bookworm-slim RUN apt-get update && apt-get install -y \ libcurl4 \ libgomp1 \ ca-certificates \ curl \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY --from=builder /build/llama.cpp/build/bin/llama-server /app/llama-server ARG MODEL_URL=https://huggingface.co/bartowski/Qwen2.5-3B-Instruct-GGUF/resolve/main/Qwen2.5-3B-Instruct-Q4_K_M.gguf RUN curl -L -o /app/model.gguf "${MODEL_URL}" EXPOSE 7860 HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 CMD ["/app/llama-server", \ "-m", "/app/model.gguf", \ "--host", "0.0.0.0", \ "--port", "7860", \ "--threads", "2", \ "--ctx-size", "24576", \ "-ngl", "0", \ "--batch-size", "512", \ "--jinja"]