cpu.Dockerfile 1.9 KB

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