KBaba7/llama.cpp
0
1ARG UBUNTU_VERSION=22.042 3FROM ubuntu:$UBUNTU_VERSION AS build4 5ARG TARGETARCH6 7ARG GGML_CPU_ARM_ARCH=armv8-a8 9RUN apt-get update && \10 apt-get install -y build-essential git cmake libcurl4-openssl-dev11 12WORKDIR /app13 14COPY . .15 16RUN if [ "$TARGETARCH" = "amd64" ]; then \17 cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON; \18 elif [ "$TARGETARCH" = "arm64" ]; then \19 cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ARM_ARCH=${GGML_CPU_ARM_ARCH}; \20 else \21 echo "Unsupported architecture"; \22 exit 1; \23 fi && \24 cmake --build build -j $(nproc)25 26RUN mkdir -p /app/lib && \27 find build -name "*.so" -exec cp {} /app/lib \;28 29RUN mkdir -p /app/full \30 && cp build/bin/* /app/full \31 && cp *.py /app/full \32 && cp -r gguf-py /app/full \33 && cp -r requirements /app/full \34 && cp requirements.txt /app/full \35 && cp .devops/tools.sh /app/full/tools.sh36 37## Base image38FROM ubuntu:$UBUNTU_VERSION AS base39 40RUN apt-get update \41 && apt-get install -y libgomp1 curl\42 && apt autoremove -y \43 && apt clean -y \44 && rm -rf /tmp/* /var/tmp/* \45 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \46 && find /var/cache -type f -delete47 48COPY --from=build /app/lib/ /app49 50### Full51FROM base AS full52 53COPY --from=build /app/full /app54 55WORKDIR /app56 57RUN apt-get update \58 && apt-get install -y \59 git \60 python3 \61 python3-pip \62 && pip install --upgrade pip setuptools wheel \63 && pip install -r requirements.txt \64 && apt autoremove -y \65 && apt clean -y \66 && rm -rf /tmp/* /var/tmp/* \67 && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \68 && find /var/cache -type f -delete69 70ENTRYPOINT ["/app/tools.sh"]71 72### Light, CLI only73FROM base AS light74 75COPY --from=build /app/full/llama-cli /app76 77WORKDIR /app78 79ENTRYPOINT [ "/app/llama-cli" ]80 81### Server, Server only82FROM base AS server83 84ENV LLAMA_ARG_HOST=0.0.0.085 86COPY --from=build /app/full/llama-server /app87 88WORKDIR /app89 90HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]91 92ENTRYPOINT [ "/app/llama-server" ]93 