char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
5d8ccdf9d
char/aliceai-t5-moe
1ARG UBUNTU_VERSION=22.04 2# This needs to generally match the container host's environment. 3ARG MUSA_VERSION=rc4.3.0 4# Target the MUSA build image 5ARG BASE_MUSA_DEV_CONTAINER=docker.io/mthreads/musa:${ MUSA_VERSION } -devel-ubuntu${ UBUNTU_VERSION } -amd64 6 7ARG BASE_MUSA_RUN_CONTAINER=docker.io/mthreads/musa:${ MUSA_VERSION } -runtime-ubuntu${ UBUNTU_VERSION } -amd64 8 9ARG BUILD_DATE=N/A 10ARG APP_VERSION=N/A 11ARG APP_REVISION=N/A 12 13ARG NODE_VERSION=24 14 15FROM docker.io/node: $ NODE_VERSION AS web 16 17ARG APP_VERSION 18 19WORKDIR /app/tools/ui 20 21COPY tools/ui/package.json tools/ui/package-lock.json ./ 22RUN npm ci 23 24COPY tools/ui/ ./ 25RUN LLAMA_BUILD_NUMBER="$APP_VERSION" npm run build 26 27FROM ${ BASE_MUSA_DEV_CONTAINER } AS build 28 29# MUSA architecture to build for (defaults to all supported archs) 30ARG MUSA_DOCKER_ARCH=default 31 32RUN apt-get update && \ 33 apt-get install -y \ 34 build-essential \ 35 cmake \ 36 python3 \ 37 python3-pip \ 38 git \ 39 libssl-dev \ 40 libgomp1 41 42WORKDIR /app 43 44COPY . . 45 46COPY --from=web /app/tools/ui/dist tools/ui/dist 47 48RUN if [ "${MUSA_DOCKER_ARCH}" != "default" ]; then \ 49 export CMAKE_ARGS="-DMUSA_ARCHITECTURES=${MUSA_DOCKER_ARCH}"; \ 50 fi && \ 51 cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_BUILD_TESTS=OFF ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \ 52 cmake --build build --config Release -j$(nproc) 53 54RUN mkdir -p /app/lib && \ 55 find build -name "*.so*" -exec cp -P {} /app/lib \; 56 57RUN mkdir -p /app/full \ 58 && cp build/bin/* /app/full \ 59 && cp *.py /app/full \ 60 && cp -r conversion /app/full \ 61 && cp -r gguf-py /app/full \ 62 && cp -r requirements /app/full \ 63 && cp requirements.txt /app/full \ 64 && cp .devops/tools.sh /app/full/tools.sh 65 66## Base image 67FROM ${ BASE_MUSA_RUN_CONTAINER } AS base 68 69ARG BUILD_DATE=N/A 70ARG APP_VERSION=N/A 71ARG APP_REVISION=N/A 72ARG IMAGE_URL=https://github.com/ggml-org/llama.cpp 73ARG IMAGE_SOURCE=https://github.com/ggml-org/llama.cpp 74LABEL org.opencontainers.image.created=$ BUILD_DATE \ 75 org.opencontainers.image.version=$ APP_VERSION \ 76 org.opencontainers.image.revision=$ APP_REVISION \ 77 org.opencontainers.image.title="llama.cpp" \ 78 org.opencontainers.image.description="LLM inference in C/C++" \ 79 org.opencontainers.image.url=$ IMAGE_URL \ 80 org.opencontainers.image.source=$ IMAGE_SOURCE 81 82RUN apt-get update \ 83 && apt-get install -y libgomp1 curl ffmpeg \ 84 && apt autoremove -y \ 85 && apt clean -y \ 86 && rm -rf /tmp/* /var/tmp/* \ 87 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \ 88 && find /var/cache -type f -delete 89 90COPY --from=build /app/lib/ /app 91 92### Full 93FROM baseAS full 94 95COPY --from=build /app/full /app 96 97WORKDIR /app 98 99RUN apt-get update \ 100 && apt-get install -y \ 101 git \ 102 python3 \ 103 python3-pip \ 104 && pip install --upgrade pip setuptools wheel \ 105 && pip install -r requirements.txt \ 106 && apt autoremove -y \ 107 && apt clean -y \ 108 && rm -rf /tmp/* /var/tmp/* \ 109 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \ 110 && find /var/cache -type f -delete 111 112 113ENTRYPOINT ["/app/tools.sh" ] 114 115### Light, CLI only 116FROM baseAS light 117 118COPY --from=build /app/full/llama /app/full/llama-cli /app/full/llama-completion /app 119 120WORKDIR /app 121 122ENTRYPOINT ["/app/llama-cli" ] 123 124### Server, Server only 125FROM baseAS server 126 127ENV LLAMA_ARG_HOST=0.0.0.0 128 129COPY --from=build /app/full/llama /app/full/llama-server /app 130 131WORKDIR /app 132 133HEALTHCHECK CMD ["curl" ,"-f" ,"http://localhost:8080/health" ] 134 135ENTRYPOINT ["/app/llama-server" ]