Skip to content

Commit 85f58f8

Browse files
committed
added docker-multi-stage builds
1 parent e52aba5 commit 85f58f8

22 files changed

+584
-585
lines changed

.devops/full.Dockerfile renamed to .devops/cpu.Dockerfile

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN cmake -S . -B build -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VA
1414
mkdir -p /app/lib && \
1515
find build -name "*.so" -exec cp {} /app/lib/ \;
1616

17-
FROM ubuntu:$UBUNTU_VERSION as runtime
17+
FROM ubuntu:$UBUNTU_VERSION as full
1818

1919
WORKDIR /app
2020

@@ -36,3 +36,37 @@ COPY --from=build /app/gguf-py /app/gguf-py
3636
ENV LC_ALL=C.utf8
3737

3838
ENTRYPOINT ["/app/tools.sh"]
39+
40+
41+
FROM ubuntu:$UBUNTU_VERSION AS light
42+
43+
WORKDIR /app
44+
45+
RUN apt-get update && \
46+
apt-get install -y libgomp1
47+
48+
COPY --from=build /app/build/bin/llama-cli /app/
49+
COPY --from=build /app/lib/ /app/
50+
51+
ENV LC_ALL=C.utf8
52+
53+
ENTRYPOINT [ "/app/llama-cli" ]
54+
55+
56+
FROM ubuntu:$UBUNTU_VERSION AS server
57+
58+
WORKDIR /app
59+
60+
RUN apt-get update && \
61+
apt-get install -y libcurl4-openssl-dev libgomp1 curl
62+
63+
COPY --from=build /app/build/bin/llama-server /app/
64+
COPY --from=build /app/lib/ /app/
65+
66+
ENV LC_ALL=C.utf8
67+
# Must be set to 0.0.0.0 so it can listen to requests from host machine
68+
ENV LLAMA_ARG_HOST=0.0.0.0
69+
70+
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
71+
72+
ENTRYPOINT [ "/app/llama-server" ]

.devops/cuda.Dockerfile

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
ARG UBUNTU_VERSION=22.04
2+
# This needs to generally match the container host's environment.
3+
ARG CUDA_VERSION=12.6.0
4+
# Target the CUDA build image
5+
ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
6+
7+
ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
8+
9+
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
10+
11+
# CUDA architecture to build for (defaults to all supported archs)
12+
ARG CUDA_DOCKER_ARCH=default
13+
14+
RUN apt-get update && \
15+
apt-get install -y build-essential cmake python3 python3-pip git libcurl4-openssl-dev libgomp1
16+
17+
WORKDIR /app
18+
19+
COPY . .
20+
21+
RUN if [ "${CUDA_DOCKER_ARCH}" != "default" ]; then \
22+
export CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=${CUDA_DOCKER_ARCH}"; \
23+
fi && \
24+
cmake -B build -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
25+
cmake --build build --config Release -j$(nproc) && \
26+
cp build/bin/* .
27+
28+
RUN mkdir -p /app/lib && \
29+
find build -name "*.so" -exec cp {} /app/lib \;
30+
31+
32+
FROM ${BASE_CUDA_RUN_CONTAINER} AS full
33+
COPY --from=build /app /app
34+
35+
WORKDIR /app
36+
37+
RUN apt-get update \
38+
&& apt-get install -y \
39+
python3 \
40+
python3-pip \
41+
git \
42+
libgomp1 \
43+
&& pip install --upgrade pip setuptools wheel \
44+
&& pip install -r requirements.txt \
45+
&& apt autoremove -y \
46+
&& apt clean -y \
47+
&& rm -rf /tmp/* /var/tmp/* \
48+
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
49+
&& find /var/cache -type f -delete
50+
51+
ENTRYPOINT ["/app/.devops/tools.sh"]
52+
53+
FROM ${BASE_CUDA_RUN_CONTAINER} AS light
54+
55+
RUN apt-get update \
56+
&& apt-get install -y libgomp1 \
57+
&& apt autoremove -y \
58+
&& apt clean -y \
59+
&& rm -rf /tmp/* /var/tmp/* \
60+
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
61+
&& find /var/cache -type f -delete
62+
63+
COPY --from=build /app/lib/ /app/
64+
COPY --from=build /app/build/bin/llama-cli /app/
65+
66+
WORKDIR /app
67+
68+
ENTRYPOINT [ "/app/llama-cli" ]
69+
70+
FROM ${BASE_CUDA_RUN_CONTAINER} AS server
71+
72+
RUN apt-get update \
73+
&& apt-get install -y libgomp1 curl \
74+
&& apt autoremove -y \
75+
&& apt clean -y \
76+
&& rm -rf /tmp/* /var/tmp/* \
77+
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
78+
&& find /var/cache -type f -delete
79+
80+
COPY --from=build /app/lib/ /app/
81+
COPY --from=build /app/build/bin/llama-server /app/
82+
83+
WORKDIR /app
84+
85+
# Must be set to 0.0.0.0 so it can listen to requests from host machine
86+
ENV LLAMA_ARG_HOST=0.0.0.0
87+
88+
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
89+
90+
ENTRYPOINT [ "/app/llama-server" ]

.devops/full-cuda.Dockerfile

Lines changed: 0 additions & 33 deletions
This file was deleted.

.devops/full-musa.Dockerfile

Lines changed: 0 additions & 33 deletions
This file was deleted.

.devops/full-rocm.Dockerfile

Lines changed: 0 additions & 50 deletions
This file was deleted.

.devops/intel.Dockerfile

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
ARG ONEAPI_VERSION=2025.0.0-0-devel-ubuntu22.04
2+
3+
## Build Image
4+
5+
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS build
6+
7+
ARG GGML_SYCL_F16=OFF
8+
RUN apt-get update && \
9+
apt-get install -y git libcurl4-openssl-dev
10+
11+
WORKDIR /app
12+
13+
COPY . .
14+
15+
RUN if [ "${GGML_SYCL_F16}" = "ON" ]; then \
16+
echo "GGML_SYCL_F16 is set" && \
17+
export OPT_SYCL_F16="-DGGML_SYCL_F16=ON"; \
18+
fi && \
19+
echo "Building with dynamic libs" && \
20+
cmake -B build -DGGML_NATIVE=OFF -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DLLAMA_CURL=ON ${OPT_SYCL_F16} && \
21+
cmake --build build --config Release -j$(nproc) && \
22+
cp build/bin/* .
23+
24+
RUN mkdir -p /app/lib && \
25+
find build -name "*.so" -exec cp {} /app/lib \;
26+
27+
FROM intel/oneapi-basekit:$ONEAPI_VERSION as full
28+
COPY --from=build /app /app
29+
30+
WORKDIR /app
31+
32+
RUN apt-get update \
33+
&& apt-get install -y \
34+
python3 \
35+
python3-pip \
36+
git \
37+
libgomp1 \
38+
&& pip install --upgrade pip setuptools wheel \
39+
&& pip install -r requirements.txt \
40+
&& apt autoremove -y \
41+
&& apt clean -y \
42+
&& rm -rf /tmp/* /var/tmp/* \
43+
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
44+
&& find /var/cache -type f -delete
45+
46+
ENTRYPOINT ["/app/.devops/tools.sh"]
47+
48+
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS light
49+
50+
RUN apt-get update \
51+
&& apt-get install -y libgomp1 \
52+
&& apt autoremove -y \
53+
&& apt clean -y \
54+
&& rm -rf /tmp/* /var/tmp/* \
55+
&& find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
56+
&& find /var/cache -type f -delete
57+
58+
COPY --from=build /app/lib/ /app/
59+
COPY --from=build /app/build/bin/llama-cli /app/
60+
61+
WORKDIR /app
62+
63+
ENTRYPOINT [ "/app/llama-cli" ]
64+
65+
66+
FROM intel/oneapi-basekit:$ONEAPI_VERSION AS server
67+
68+
RUN apt-get update \
69+
&& apt-get install -y libgomp1 curl \
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+
76+
COPY --from=build /app/lib/ /app/
77+
COPY --from=build /app/build/bin/llama-server /app/
78+
79+
WORKDIR /app
80+
81+
# Must be set to 0.0.0.0 so it can listen to requests from host machine
82+
ENV LLAMA_ARG_HOST=0.0.0.0
83+
84+
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
85+
86+
ENTRYPOINT [ "/app/llama-server" ]

.devops/llama-cli-cuda.Dockerfile

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)