1ARG UBUNTU_VERSION=26.04
2
3FROM ubuntu:$UBUNTU_VERSION AS build
4
5# Install build tools
6RUN apt update && apt install -y git build-essential cmake wget xz-utils
7
8# Install SSL and Vulkan SDK dependencies
9RUN apt install -y libssl-dev curl \
10 libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libvulkan-dev glslc
11
12# Build it
13WORKDIR /app
14
15COPY . .
16
17RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_VULKAN=ON -DLLAMA_BUILD_TESTS=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON && \
18 cmake --build build --config Release -j$(nproc)
19
20RUN mkdir -p /app/lib && \
21 find build -name "*.so*" -exec cp -P {} /app/lib \;
22
23RUN mkdir -p /app/full \
24 && cp build/bin/* /app/full \
25 && cp *.py /app/full \
26 && cp -r gguf-py /app/full \
27 && cp -r requirements /app/full \
28 && cp requirements.txt /app/full \
29 && cp .devops/tools.sh /app/full/tools.sh
30
31## Base image
32FROM ubuntu:$UBUNTU_VERSION AS base
33
34RUN apt-get update \
35 && apt-get install -y libgomp1 curl libvulkan1 mesa-vulkan-drivers \
36 libglvnd0 libgl1 libglx0 libegl1 libgles2 \
37 && apt autoremove -y \
38 && apt clean -y \
39 && rm -rf /tmp/* /var/tmp/* \
40 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
41 && find /var/cache -type f -delete
42
43COPY --from=build /app/lib/ /app
44
45### Full
46FROM base AS full
47
48COPY --from=build /app/full /app
49
50WORKDIR /app
51
52RUN apt-get update \
53 && apt-get install -y \
54 build-essential \
55 git \
56 python3 \
57 python3-dev \
58 python3-pip \
59 python3-wheel \
60 && pip install --break-system-packages --upgrade setuptools \
61 && pip install --break-system-packages -r requirements.txt \
62 && apt autoremove -y \
63 && apt clean -y \
64 && rm -rf /tmp/* /var/tmp/* \
65 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
66 && find /var/cache -type f -delete
67
68ENTRYPOINT ["/app/tools.sh"]
69
70### Light, CLI only
71FROM base AS light
72
73COPY --from=build /app/full/llama-cli /app/full/llama-completion /app
74
75WORKDIR /app
76
77ENTRYPOINT [ "/app/llama-cli" ]
78
79### Server, Server only
80FROM base AS server
81
82ENV LLAMA_ARG_HOST=0.0.0.0
83
84COPY --from=build /app/full/llama-server /app
85
86WORKDIR /app
87
88HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
89
90ENTRYPOINT [ "/app/llama-server" ]