fable5-inference / Dockerfile
Leon4gr45's picture
build: use prebuilt llama.cpp CPU binary (b9895) instead of source compile — fixes mtmd OOM hang, ~20x faster build
ea5d56a verified
Raw
History Blame Contribute Delete
2.2 kB
# Ubuntu 24.04 base to match the glibc of the official llama.cpp release binary.
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime deps only (no compiler/cmake — we use the prebuilt binary).
# libgomp1 : OpenMP threading used by ggml-cpu
# libcurl4 : llama-server is built with curl support
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
libgomp1 \
libcurl4 \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Python runtime deps (thin FastAPI proxy)
RUN pip install --no-cache-dir --break-system-packages \
fastapi \
uvicorn \
httpx \
huggingface_hub
# ---------------------------------------------------------------------------
# Prebuilt llama.cpp CPU server — NO source compile (avoids the multimodal/mtmd
# OOM that hangs a from-source build on a 2-vCPU builder). The ubuntu-x64 build
# ships per-microarch CPU variants (haswell/skylakex/icelake/...) and selects the
# best one at RUNTIME, so it is portable and safe on cpu-basic.
# ---------------------------------------------------------------------------
ARG LLAMA_TAG=b9895
RUN mkdir -p /llama.cpp/build/bin \
&& curl -fsSL -o /tmp/llama.tar.gz \
"https://github.com/ggml-org/llama.cpp/releases/download/${LLAMA_TAG}/llama-${LLAMA_TAG}-bin-ubuntu-x64.tar.gz" \
&& tar -xzf /tmp/llama.tar.gz -C /llama.cpp/build/bin --strip-components=1 \
&& rm /tmp/llama.tar.gz \
&& chmod +x /llama.cpp/build/bin/llama-server \
&& /llama.cpp/build/bin/llama-server --version 2>&1 | head -5
# llama-server finds its sibling .so files here.
ENV LD_LIBRARY_PATH=/llama.cpp/build/bin
WORKDIR /app
# Models directory (model is pulled at container startup by app.py, not baked
# into the image — keeps the build fast and avoids download hangs during build).
RUN mkdir -p /models && chmod -R 777 /models
COPY . .
# Single instance: main proxy (7860) + one llama.cpp server (8081)
EXPOSE 7860 8081
# Longer start-period: the model (~5.5GB) is pulled on first container start.
HEALTHCHECK --interval=30s --timeout=10s --start-period=420s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
CMD ["python3", "app.py"]