musa.Dockerfile 2.7 KB

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