vulkan.Dockerfile 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ARG UBUNTU_VERSION=jammy
  2. FROM ubuntu:$UBUNTU_VERSION AS build
  3. # Install build tools
  4. RUN apt update && apt install -y git build-essential cmake wget
  5. # Install Vulkan SDK and cURL
  6. RUN wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | apt-key add - && \
  7. wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list && \
  8. apt update -y && \
  9. apt-get install -y vulkan-sdk libcurl4-openssl-dev curl
  10. # Build it
  11. WORKDIR /app
  12. COPY . .
  13. RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_VULKAN=1 -DLLAMA_CURL=1 && \
  14. cmake --build build --config Release -j$(nproc)
  15. RUN mkdir -p /app/lib && \
  16. find build -name "*.so" -exec cp {} /app/lib \;
  17. RUN mkdir -p /app/full \
  18. && cp build/bin/* /app/full \
  19. && cp *.py /app/full \
  20. && cp -r gguf-py /app/full \
  21. && cp -r requirements /app/full \
  22. && cp requirements.txt /app/full \
  23. && cp .devops/tools.sh /app/full/tools.sh
  24. ## Base image
  25. FROM ubuntu:$UBUNTU_VERSION AS base
  26. RUN apt-get update \
  27. && apt-get install -y libgomp1 curl\
  28. && apt autoremove -y \
  29. && apt clean -y \
  30. && rm -rf /tmp/* /var/tmp/* \
  31. && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
  32. && find /var/cache -type f -delete
  33. COPY --from=build /app/lib/ /app
  34. ### Full
  35. FROM base AS full
  36. COPY --from=build /app/full /app
  37. WORKDIR /app
  38. RUN apt-get update \
  39. && apt-get install -y \
  40. git \
  41. python3 \
  42. python3-pip \
  43. && pip install --upgrade pip setuptools wheel \
  44. && pip install -r requirements.txt \
  45. && apt autoremove -y \
  46. && apt clean -y \
  47. && rm -rf /tmp/* /var/tmp/* \
  48. && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
  49. && find /var/cache -type f -delete
  50. ENTRYPOINT ["/app/tools.sh"]
  51. ### Light, CLI only
  52. FROM base AS light
  53. COPY --from=build /app/full/llama-cli /app
  54. WORKDIR /app
  55. ENTRYPOINT [ "/app/llama-cli" ]
  56. ### Server, Server only
  57. FROM base AS server
  58. ENV LLAMA_ARG_HOST=0.0.0.0
  59. COPY --from=build /app/full/llama-server /app
  60. WORKDIR /app
  61. HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
  62. ENTRYPOINT [ "/app/llama-server" ]