musa.Dockerfile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ARG UBUNTU_VERSION=22.04
  2. # This needs to generally match the container host's environment.
  3. ARG MUSA_VERSION=rc4.2.0
  4. # Target the MUSA build image
  5. ARG BASE_MUSA_DEV_CONTAINER=mthreads/musa:${MUSA_VERSION}-devel-ubuntu${UBUNTU_VERSION}-amd64
  6. ARG BASE_MUSA_RUN_CONTAINER=mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}-amd64
  7. FROM ${BASE_MUSA_DEV_CONTAINER} AS build
  8. # MUSA architecture to build for (defaults to all supported archs)
  9. ARG MUSA_DOCKER_ARCH=default
  10. RUN apt-get update && \
  11. apt-get install -y \
  12. build-essential \
  13. cmake \
  14. python3 \
  15. python3-pip \
  16. git \
  17. libcurl4-openssl-dev \
  18. libgomp1
  19. WORKDIR /app
  20. COPY . .
  21. RUN if [ "${MUSA_DOCKER_ARCH}" != "default" ]; then \
  22. export CMAKE_ARGS="-DMUSA_ARCHITECTURES=${MUSA_DOCKER_ARCH}"; \
  23. fi && \
  24. cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_BUILD_TESTS=OFF ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
  25. cmake --build build --config Release -j$(nproc)
  26. RUN mkdir -p /app/lib && \
  27. find build -name "*.so" -exec cp {} /app/lib \;
  28. RUN mkdir -p /app/full \
  29. && cp build/bin/* /app/full \
  30. && cp *.py /app/full \
  31. && cp -r gguf-py /app/full \
  32. && cp -r requirements /app/full \
  33. && cp requirements.txt /app/full \
  34. && cp .devops/tools.sh /app/full/tools.sh
  35. ## Base image
  36. FROM ${BASE_MUSA_RUN_CONTAINER} AS base
  37. RUN apt-get update \
  38. && apt-get install -y libgomp1 curl\
  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. COPY --from=build /app/lib/ /app
  45. ### Full
  46. FROM base AS full
  47. COPY --from=build /app/full /app
  48. WORKDIR /app
  49. RUN apt-get update \
  50. && apt-get install -y \
  51. git \
  52. python3 \
  53. python3-pip \
  54. && pip install --upgrade pip setuptools wheel \
  55. && pip install -r requirements.txt \
  56. && apt autoremove -y \
  57. && apt clean -y \
  58. && rm -rf /tmp/* /var/tmp/* \
  59. && find /var/cache/apt/archives /var/lib/apt/lists -not -name lock -type f -delete \
  60. && find /var/cache -type f -delete
  61. ENTRYPOINT ["/app/tools.sh"]
  62. ### Light, CLI only
  63. FROM base AS light
  64. COPY --from=build /app/full/llama-cli /app
  65. WORKDIR /app
  66. ENTRYPOINT [ "/app/llama-cli" ]
  67. ### Server, Server only
  68. FROM base AS server
  69. ENV LLAMA_ARG_HOST=0.0.0.0
  70. COPY --from=build /app/full/llama-server /app
  71. WORKDIR /app
  72. HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
  73. ENTRYPOINT [ "/app/llama-server" ]