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.0 KiB117 linesraw
1ARG UBUNTU_VERSION=24.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
22RUN apt-get update && \
23    apt-get install -y gcc-13 g++-13 build-essential git cmake libssl-dev libomp-dev libnuma-dev python3 ca-certificates
24
25ENV CC=gcc-13 CXX=g++-13
26
27WORKDIR /app
28
29COPY . .
30
31COPY --from=web /app/tools/ui/dist tools/ui/dist
32
33RUN cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DGGML_NATIVE=OFF -DLLAMA_BUILD_TESTS=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_ZENDNN=ON && \
34    cmake --build build -j $(nproc)
35
36RUN mkdir -p /app/lib && \
37    find build -name "*.so*" -exec cp -P {} /app/lib \;
38
39RUN mkdir -p /app/full \
40    && cp build/bin/* /app/full \
41    && cp *.py /app/full \
42    && cp -r conversion /app/full \
43    && cp -r gguf-py /app/full \
44    && cp -r requirements /app/full \
45    && cp requirements.txt /app/full \
46    && cp .devops/tools.sh /app/full/tools.sh
47
48## Base image
49FROM docker.io/ubuntu:$UBUNTU_VERSION AS base
50
51ARG BUILD_DATE=N/A
52ARG APP_VERSION=N/A
53ARG APP_REVISION=N/A
54ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp
55ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp
56LABEL org.opencontainers.image.created=$BUILD_DATE \
57      org.opencontainers.image.version=$APP_VERSION \
58      org.opencontainers.image.revision=$APP_REVISION \
59      org.opencontainers.image.title="llama.cpp" \
60      org.opencontainers.image.description="LLM inference in C/C++" \
61      org.opencontainers.image.url=$IMAGE_URL \
62      org.opencontainers.image.source=$IMAGE_SOURCE
63
64RUN apt-get update \
65    && apt-get install -y libgomp1 libnuma1 curl ffmpeg \
66    && apt autoremove -y \
67    && apt clean -y \
68    && rm -rf /tmp/* /var/tmp/* \
69    && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
70    && find /var/cache -type f -delete
71
72COPY --from=build /app/lib/ /app
73
74### Full
75FROM base AS full
76
77COPY --from=build /app/full /app
78
79WORKDIR /app
80
81RUN apt-get update \
82    && apt-get install -y \
83    git \
84    python3 \
85    python3-pip \
86    python3-wheel \
87    && pip install --break-system-packages --upgrade setuptools \
88    && pip install --break-system-packages -r requirements.txt \
89    && apt autoremove -y \
90    && apt clean -y \
91    && rm -rf /tmp/* /var/tmp/* \
92    && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
93    && find /var/cache -type f -delete
94
95ENTRYPOINT ["/app/tools.sh"]
96
97### Light, CLI only
98FROM base AS light
99
100COPY --from=build /app/full/llama /app/full/llama-cli /app/full/llama-completion /app
101
102WORKDIR /app
103
104ENTRYPOINT [ "/app/llama-cli" ]
105
106### Server, Server only
107FROM base AS server
108
109ENV LLAMA_ARG_HOST=0.0.0.0
110
111COPY --from=build /app/full/llama /app/full/llama-server /app
112
113WORKDIR /app
114
115HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
116
117ENTRYPOINT [ "/app/llama-server" ]