cpu.Dockerfile 2.2 KB

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