File size: 1,720 Bytes
4baaa2f
 
36fcbf8
4baaa2f
 
 
 
 
 
 
 
 
 
36fcbf8
4baaa2f
 
 
 
 
36fcbf8
4baaa2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36fcbf8
 
 
4baaa2f
 
 
 
 
36fcbf8
4baaa2f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Ubuntu 24.04 base to match the glibc of the official llama.cpp release binary.
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
    curl \
    ca-certificates \
    libgomp1 \
    libcurl4 \
    python3 \
    python3-pip \
    && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir --break-system-packages \
    fastapi \
    uvicorn \
    httpx \
    huggingface_hub

# ---------------------------------------------------------------------------
# Prebuilt llama.cpp CPU server (includes libmtmd -> vision support). No source
# compile: avoids the multimodal OOM that hangs a from-source build on 2 vCPUs.
# Ships per-microarch CPU variants selected at runtime -> portable & safe.
# ---------------------------------------------------------------------------
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

ENV LD_LIBRARY_PATH=/llama.cpp/build/bin

WORKDIR /app

# Models (text GGUF + mmproj projector) are pulled at container startup by app.py.
RUN mkdir -p /models && chmod -R 777 /models

COPY . .

EXPOSE 7860 8081

# Vision model + projector are small (~1.5GB total); start-period covers download.
HEALTHCHECK --interval=30s --timeout=10s --start-period=300s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

CMD ["python3", "app.py"]