1
0

vulkan.Dockerfile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ARG UBUNTU_VERSION=24.04
  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-noble.list https://packages.lunarg.com/vulkan/lunarg-vulkan-noble.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 -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON && \
  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 libvulkan-dev \
  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. python3-wheel \
  44. && pip install --break-system-packages --upgrade setuptools \
  45. && pip install --break-system-packages -r requirements.txt \
  46. && apt autoremove -y \
  47. && apt clean -y \
  48. && rm -rf /tmp/* /var/tmp/* \
  49. && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
  50. && find /var/cache -type f -delete
  51. ENTRYPOINT ["/app/tools.sh"]
  52. ### Light, CLI only
  53. FROM base AS light
  54. COPY --from=build /app/full/llama-cli /app
  55. WORKDIR /app
  56. ENTRYPOINT [ "/app/llama-cli" ]
  57. ### Server, Server only
  58. FROM base AS server
  59. ENV LLAMA_ARG_HOST=0.0.0.0
  60. COPY --from=build /app/full/llama-server /app
  61. WORKDIR /app
  62. HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
  63. ENTRYPOINT [ "/app/llama-server" ]