File size: 2,113 Bytes
ea5d56a
 
c5c5d80
ea5d56a
 
dfdf6b0
687f798
 
ea5d56a
e24791f
ea5d56a
687f798
 
ea5d56a
dfdf6b0
ea5d56a
 
 
 
 
 
 
 
 
 
 
 
dfdf6b0
 
 
 
 
 
 
 
 
 
 
c5c5d80
 
dfdf6b0
0656d63
687f798
dfdf6b0
 
c5c5d80
dfdf6b0
687f798
dfdf6b0
ea5d56a
687f798
c5c5d80
dfdf6b0
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
52
53
54
# 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 — prebuilt binaries).
RUN apt-get update && apt-get install -y \
    curl \
    ca-certificates \
    libgomp1 \
    libcurl4 \
    && rm -rf /var/lib/apt/lists/*

# ---------------------------------------------------------------------------
# Prebuilt llama.cpp CPU server (per-microarch variants selected at runtime).
# ---------------------------------------------------------------------------
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

# ---------------------------------------------------------------------------
# llama-swap: model-swapping proxy — routes by the request's "model" field.
# ---------------------------------------------------------------------------
ARG SWAP_VERSION=236
RUN curl -fsSL -o /tmp/llama-swap.tar.gz \
       "https://github.com/mostlygeek/llama-swap/releases/download/v${SWAP_VERSION}/llama-swap_${SWAP_VERSION}_linux_amd64.tar.gz" \
    && tar -xzf /tmp/llama-swap.tar.gz -C /usr/local/bin llama-swap \
    && rm /tmp/llama-swap.tar.gz \
    && chmod +x /usr/local/bin/llama-swap \
    && /usr/local/bin/llama-swap --version

WORKDIR /app

# Models are pulled at container startup by entrypoint.sh (keeps builds fast).
RUN mkdir -p /models && chmod -R 777 /models

COPY config.yaml entrypoint.sh ./
RUN chmod +x /app/entrypoint.sh

EXPOSE 7860

# Two ~1.3GB models are pulled on first start.
HEALTHCHECK --interval=30s --timeout=10s --start-period=420s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

CMD ["/app/entrypoint.sh"]