cpu.Dockerfile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. ARG UBUNTU_VERSION=22.04
  2. FROM ubuntu:$UBUNTU_VERSION AS build
  3. ARG TARGETARCH
  4. RUN apt-get update && \
  5. apt-get install -y build-essential git cmake libcurl4-openssl-dev
  6. WORKDIR /app
  7. COPY . .
  8. RUN if [ "$TARGETARCH" = "amd64" ]; then \
  9. cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON; \
  10. else \
  11. cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLLAMA_CURL=ON; \
  12. fi && \
  13. cmake --build build -j $(nproc)
  14. RUN mkdir -p /app/lib && \
  15. find build -name "*.so" -exec cp {} /app/lib \;
  16. RUN mkdir -p /app/full \
  17. && cp build/bin/* /app/full \
  18. && cp *.py /app/full \
  19. && cp -r gguf-py /app/full \
  20. && cp -r requirements /app/full \
  21. && cp requirements.txt /app/full \
  22. && cp .devops/tools.sh /app/full/tools.sh
  23. ## Base image
  24. FROM ubuntu:$UBUNTU_VERSION AS base
  25. RUN apt-get update \
  26. && apt-get install -y libgomp1 curl\
  27. && apt autoremove -y \
  28. && apt clean -y \
  29. && rm -rf /tmp/* /var/tmp/* \
  30. && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
  31. && find /var/cache -type f -delete
  32. COPY --from=build /app/lib/ /app
  33. ### Full
  34. FROM base AS full
  35. COPY --from=build /app/full /app
  36. WORKDIR /app
  37. RUN apt-get update \
  38. && apt-get install -y \
  39. git \
  40. python3 \
  41. python3-pip \
  42. && pip install --upgrade pip setuptools wheel \
  43. && pip install -r requirements.txt \
  44. && apt autoremove -y \
  45. && apt clean -y \
  46. && rm -rf /tmp/* /var/tmp/* \
  47. && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
  48. && find /var/cache -type f -delete
  49. ENTRYPOINT ["/app/tools.sh"]
  50. ### Light, CLI only
  51. FROM base AS light
  52. COPY --from=build /app/full/llama-cli /app
  53. WORKDIR /app
  54. ENTRYPOINT [ "/app/llama-cli" ]
  55. ### Server, Server only
  56. FROM base AS server
  57. ENV LLAMA_ARG_HOST=0.0.0.0
  58. COPY --from=build /app/full/llama-server /app
  59. WORKDIR /app
  60. HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
  61. ENTRYPOINT [ "/app/llama-server" ]