Felipe97/llama-cpp-compiled
01.1k
1ARG UBUNTU_VERSION=26.042ARG BUILD_DATE=N/A3ARG APP_VERSION=N/A4ARG APP_REVISION=N/A5 6ARG NODE_VERSION=247 8FROM docker.io/node:$NODE_VERSION AS web9 10ARG APP_VERSION11 12WORKDIR /app/tools/ui13 14COPY tools/ui/package.json tools/ui/package-lock.json ./15RUN npm ci16 17COPY tools/ui/ ./18RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build19 20FROM docker.io/ubuntu:$UBUNTU_VERSION AS build21 22# Install build tools23RUN apt update && apt install -y git build-essential cmake wget xz-utils24 25# Install SSL and Vulkan SDK dependencies26RUN apt install -y libssl-dev curl \27 libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libvulkan-dev glslc spirv-headers28 29# Build it30WORKDIR /app31 32COPY . .33 34COPY --from=web /app/tools/ui/dist tools/ui/dist35 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.sh50 51## Base image52FROM docker.io/ubuntu:$UBUNTU_VERSION AS base53 54ARG BUILD_DATE=N/A55ARG APP_VERSION=N/A56ARG APP_REVISION=N/A57ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp58ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp59LABEL 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_SOURCE66 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 -delete75 76COPY --from=build /app/lib/ /app77 78### Full79FROM base AS full80 81COPY --from=build /app/full /app82 83WORKDIR /app84 85ENV PATH="/root/.venv/bin:/root/.local/bin:${PATH}"86 87# Flag for compatibility with pip88ARG 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 -delete104 105ENTRYPOINT ["/app/tools.sh"]106 107### Light, CLI only108FROM base AS light109 110COPY --from=build /app/full/llama /app/full/llama-cli /app/full/llama-completion /app111 112WORKDIR /app113 114ENTRYPOINT [ "/app/llama-cli" ]115 116### Server, Server only117FROM base AS server118 119ENV LLAMA_ARG_HOST=0.0.0.0120 121COPY --from=build /app/full/llama /app/full/llama-server /app122 123WORKDIR /app124 125HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]126 127ENTRYPOINT [ "/app/llama-server" ]128 