char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Adrien Gallouëtdevops : add llama in all docker images (#25035)5d8ccdf9d

char/aliceai-t5-moe
3.4 KiB127 linesraw
1ARG UBUNTU_VERSION=26.04
2ARG BUILD_DATE=N/A
3ARG APP_VERSION=N/A
4ARG APP_REVISION=N/A
5
6ARG NODE_VERSION=24
7
8FROM docker.io/node:$NODE_VERSION AS web
9
10ARG APP_VERSION
11
12WORKDIR /app/tools/ui
13
14COPY tools/ui/package.json tools/ui/package-lock.json ./
15RUN npm ci
16
17COPY tools/ui/ ./
18RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build
19
20FROM docker.io/ubuntu:$UBUNTU_VERSION AS build
21
22# Install build tools
23RUN apt update && apt install -y git build-essential cmake wget xz-utils
24
25# Install SSL and Vulkan SDK dependencies
26RUN apt install -y libssl-dev curl \
27    libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libvulkan-dev glslc spirv-headers
28
29# Build it
30WORKDIR /app
31
32COPY . .
33
34COPY --from=web /app/tools/ui/dist tools/ui/dist
35
36RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_VULKAN=ON -DLLAMA_BUILD_TESTS=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON && \
37    cmake --build build --config Release -j$(nproc)
38
39RUN mkdir -p /app/lib && \
40    find build -name "*.so*" -exec cp -P {} /app/lib \;
41
42RUN mkdir -p /app/full \
43    && cp build/bin/* /app/full \
44    && cp *.py /app/full \
45    && cp -r conversion /app/full \
46    && cp -r gguf-py /app/full \
47    && cp -r requirements /app/full \
48    && cp requirements.txt /app/full \
49    && cp .devops/tools.sh /app/full/tools.sh
50
51## Base image
52FROM docker.io/ubuntu:$UBUNTU_VERSION AS base
53
54ARG BUILD_DATE=N/A
55ARG APP_VERSION=N/A
56ARG APP_REVISION=N/A
57ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
58ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
59LABEL org.opencontainers.image.created=$BUILD_DATE \
60      org.opencontainers.image.version=$APP_VERSION \
61      org.opencontainers.image.revision=$APP_REVISION \
62      org.opencontainers.image.title="llama.cpp" \
63      org.opencontainers.image.description="LLM inference in C/C++" \
64      org.opencontainers.image.url=$IMAGE_URL \
65      org.opencontainers.image.source=$IMAGE_SOURCE
66
67RUN apt-get update \
68    && apt-get install -y libgomp1 curl ffmpeg libvulkan1 mesa-vulkan-drivers \
69    libglvnd0 libgl1 libglx0 libegl1 libgles2 \
70    && apt autoremove -y \
71    && apt clean -y \
72    && rm -rf /tmp/* /var/tmp/* \
73    && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
74    && find /var/cache -type f -delete
75
76COPY --from=build /app/lib/ /app
77
78### Full
79FROM base AS full
80
81COPY --from=build /app/full /app
82
83WORKDIR /app
84
85ENV PATH="/root/.venv/bin:/root/.local/bin:${PATH}"
86
87# Flag for compatibility with pip
88ARG UV_INDEX_STRATEGY="unsafe-best-match"
89RUN apt-get update \
90    && apt-get install -y \
91    build-essential \
92    curl \
93    git \
94    ca-certificates \
95    && curl -LsSf https://astral.sh/uv/install.sh | sh \
96    && uv python install 3.13 \
97    && uv venv --python 3.13 /root/.venv \
98    && uv pip install --python /root/.venv/bin/python -r requirements.txt \
99    && apt autoremove -y \
100    && apt clean -y \
101    && rm -rf /tmp/* /var/tmp/* \
102    && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
103    && find /var/cache -type f -delete
104
105ENTRYPOINT ["/app/tools.sh"]
106
107### Light, CLI only
108FROM base AS light
109
110COPY --from=build /app/full/llama /app/full/llama-cli /app/full/llama-completion /app
111
112WORKDIR /app
113
114ENTRYPOINT [ "/app/llama-cli" ]
115
116### Server, Server only
117FROM base AS server
118
119ENV LLAMA_ARG_HOST=0.0.0.0
120
121COPY --from=build /app/full/llama /app/full/llama-server /app
122
123WORKDIR /app
124
125HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
126
127ENTRYPOINT [ "/app/llama-server" ]