1ARG ONEAPI_VERSION=2025.2.2-0-devel-ubuntu24.04
 2
 3## Build Image
 4
 5FROM intel/deep-learning-essentials:$ONEAPI_VERSION AS build
 6
 7ARG GGML_SYCL_F16=OFF
 8RUN apt-get update && \
 9    apt-get install -y git libssl-dev
10
11WORKDIR /app
12
13COPY . .
14
15RUN 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 -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_BUILD_TESTS=OFF ${OPT_SYCL_F16} && \
21    cmake --build build --config Release -j$(nproc)
22
23RUN mkdir -p /app/lib && \
24    find build -name "*.so*" -exec cp -P {} /app/lib \;
25
26RUN mkdir -p /app/full \
27    && cp build/bin/* /app/full \
28    && cp *.py /app/full \
29    && cp -r gguf-py /app/full \
30    && cp -r requirements /app/full \
31    && cp requirements.txt /app/full \
32    && cp .devops/tools.sh /app/full/tools.sh
33
34FROM intel/deep-learning-essentials:$ONEAPI_VERSION AS base
35
36RUN apt-get update \
37    && apt-get install -y libgomp1 curl\
38    && apt autoremove -y \
39    && apt clean -y \
40    && rm -rf /tmp/* /var/tmp/* \
41    && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
42    && find /var/cache -type f -delete
43
44### Full
45FROM base AS full
46
47COPY --from=build /app/lib/ /app
48COPY --from=build /app/full /app
49
50WORKDIR /app
51
52RUN apt-get update && \
53    apt-get install -y \
54        git \
55        python3 \
56        python3-pip \
57        python3-venv && \
58    python3 -m venv /opt/venv && \
59    . /opt/venv/bin/activate && \
60    pip install --upgrade pip setuptools wheel && \
61    pip install -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
68ENV PATH="/opt/venv/bin:$PATH"
69
70ENTRYPOINT ["/app/tools.sh"]
71
72### Light, CLI only
73FROM base AS light
74
75COPY --from=build /app/lib/ /app
76COPY --from=build /app/full/llama-cli /app/full/llama-completion /app
77
78WORKDIR /app
79
80ENTRYPOINT [ "/app/llama-cli" ]
81
82### Server, Server only
83FROM base AS server
84
85ENV LLAMA_ARG_HOST=0.0.0.0
86
87COPY --from=build /app/lib/ /app
88COPY --from=build /app/full/llama-server /app
89
90WORKDIR /app
91
92HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
93
94ENTRYPOINT [ "/app/llama-server" ]
95