Felipe97/llama-cpp-compiled
01.1k
1ARG UBUNTU_VERSION=24.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 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-certificates24 25ENV CC=gcc-13 CXX=g++-1326 27WORKDIR /app28 29COPY . .30 31COPY --from=web /app/tools/ui/dist tools/ui/dist32 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.sh47 48## Base image49FROM docker.io/ubuntu:$UBUNTU_VERSION AS base50 51ARG BUILD_DATE=N/A52ARG APP_VERSION=N/A53ARG APP_REVISION=N/A54ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp55ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp56LABEL 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_SOURCE63 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 -delete71 72COPY --from=build /app/lib/ /app73 74### Full75FROM base AS full76 77COPY --from=build /app/full /app78 79WORKDIR /app80 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 -delete94 95ENTRYPOINT ["/app/tools.sh"]96 97### Light, CLI only98FROM base AS light99 100COPY --from=build /app/full/llama /app/full/llama-cli /app/full/llama-completion /app101 102WORKDIR /app103 104ENTRYPOINT [ "/app/llama-cli" ]105 106### Server, Server only107FROM base AS server108 109ENV LLAMA_ARG_HOST=0.0.0.0110 111COPY --from=build /app/full/llama /app/full/llama-server /app112 113WORKDIR /app114 115HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]116 117ENTRYPOINT [ "/app/llama-server" ]118 