|
1 | | -# This Dockerfile is sourced from the official vLLM project: |
2 | | -# https://github.com/vllm-project/vllm/blob/main/docker/Dockerfile.cpu |
3 | | -# |
4 | | -# To build the CPU base image for HoML, you should: |
5 | | -# 1. Clone the vLLM repository: git clone https://github.com/vllm-project/vllm.git |
6 | | -# 2. Navigate to the vLLM repository root. |
7 | | -# 3. Place this file at the root of the vLLM project checkout. |
8 | | -# 4. Run the build command, e.g.: |
9 | | -# docker buildx build -t homl/vllm-cpu:latest -f Dockerfile.cpu . |
10 | | -# |
11 | | -# The resulting `homl/vllm-cpu:latest` image can then be used as a base |
12 | | -# for the main HoML server image. |
| 1 | +# This Dockerfile builds the final HoML Server image for CPU. |
| 2 | +# It layers the HoML server code on top of a pre-built vLLM CPU base image. |
| 3 | +FROM ghcr.io/wsmlby/homl-vllm-cpu-base:latest |
13 | 4 |
|
14 | | -######################### COMMON BASE IMAGE ######################### |
15 | | -FROM ubuntu:22.04 AS base-common |
16 | 5 |
|
17 | | -WORKDIR /workspace/ |
| 6 | +# Set the working directory to homl_server |
| 7 | +WORKDIR /app/homl_server |
18 | 8 |
|
19 | | -ARG PYTHON_VERSION=3.12 |
20 | | -ARG PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cpu" |
21 | 9 |
|
22 | | -# Install minimal dependencies and uv |
23 | | -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
24 | | - --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
25 | | - apt-get update -y \ |
26 | | - && apt-get install -y --no-install-recommends ccache git curl wget ca-certificates \ |
27 | | - gcc-12 g++-12 libtcmalloc-minimal4 libnuma-dev ffmpeg libsm6 libxext6 libgl1 jq lsof \ |
28 | | - && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 --slave /usr/bin/g++ g++ /usr/bin/g++-12 \ |
29 | | - && curl -LsSf https://astral.sh/uv/install.sh | sh |
| 10 | +# Copy requirements.txt and install dependencies |
| 11 | +COPY requirements.txt ./ |
| 12 | +RUN pip install -r requirements.txt |
30 | 13 |
|
31 | | -ENV CCACHE_DIR=/root/.cache/ccache |
32 | | -ENV CMAKE_CXX_COMPILER_LAUNCHER=ccache |
| 14 | +# ENV ACCELERATOR=CPU |
33 | 15 |
|
34 | | -ENV PATH="/root/.local/bin:$PATH" |
35 | | -ENV VIRTUAL_ENV="/opt/venv" |
36 | | -ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python |
37 | | -RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV} |
38 | | -ENV PATH="$VIRTUAL_ENV/bin:$PATH" |
| 16 | +# Copy our application source code |
| 17 | +COPY ./homl_server ./ |
| 18 | +COPY ./homl_server ./homl_server |
| 19 | +COPY ./vllm_patches ./patches |
39 | 20 |
|
40 | | -ENV UV_HTTP_TIMEOUT=500 |
| 21 | +RUN cd /usr/local/lib/python3.12/dist-packages/vllm && patch -p1 < /app/patches/registry.patch |
41 | 22 |
|
42 | | -# Install Python dependencies |
43 | | -ENV PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL} |
44 | | -ENV UV_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL} |
45 | | -ENV UV_INDEX_STRATEGY="unsafe-best-match" |
46 | | -ENV UV_LINK_MODE="copy" |
47 | | -RUN --mount=type=cache,target=/root/.cache/uv \ |
48 | | - --mount=type=bind,src=requirements/common.txt,target=requirements/common.txt \ |
49 | | - --mount=type=bind,src=requirements/cpu.txt,target=requirements/cpu.txt \ |
50 | | - uv pip install --upgrade pip && \ |
51 | | - uv pip install -r requirements/cpu.txt |
52 | 23 |
|
53 | | -ARG TARGETARCH |
54 | | -ENV TARGETARCH=${TARGETARCH} |
| 24 | +ARG HOML_SERVER_VERSION=dev |
| 25 | +ENV HOML_SERVER_VERSION=$HOML_SERVER_VERSION |
55 | 26 |
|
56 | | -######################### x86_64 BASE IMAGE ######################### |
57 | | -FROM base-common AS base-amd64 |
58 | | - |
59 | | -ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4:/opt/venv/lib/libiomp5.so" |
60 | | - |
61 | | -######################### arm64 BASE IMAGE ######################### |
62 | | -FROM base-common AS base-arm64 |
63 | | - |
64 | | -ENV LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libtcmalloc_minimal.so.4" |
65 | | - |
66 | | -######################### BASE IMAGE ######################### |
67 | | -FROM base-${TARGETARCH} AS base |
68 | | - |
69 | | -RUN echo 'ulimit -c 0' >> ~/.bashrc |
70 | | - |
71 | | -######################### BUILD IMAGE ######################### |
72 | | -FROM base AS vllm-build |
73 | | - |
74 | | -ARG GIT_REPO_CHECK=0 |
75 | | -# Support for building with non-AVX512 vLLM: docker build --build-arg VLLM_CPU_DISABLE_AVX512="true" ... |
76 | | -ARG VLLM_CPU_DISABLE_AVX512=true |
77 | | -ENV VLLM_CPU_DISABLE_AVX512=${VLLM_CPU_DISABLE_AVX512} |
78 | | -# Support for building with AVX512BF16 ISA: docker build --build-arg VLLM_CPU_AVX512BF16="true" ... |
79 | | -ARG VLLM_CPU_AVX512BF16=false |
80 | | -ENV VLLM_CPU_AVX512BF16=${VLLM_CPU_AVX512BF16} |
81 | | -# Support for building with AVX512VNNI ISA: docker build --build-arg VLLM_CPU_AVX512VNNI="true" ... |
82 | | -ARG VLLM_CPU_AVX512VNNI=false |
83 | | -ENV VLLM_CPU_AVX512VNNI=${VLLM_CPU_AVX512VNNI} |
84 | | - |
85 | | -WORKDIR /workspace/vllm |
86 | | - |
87 | | -RUN --mount=type=cache,target=/root/.cache/uv \ |
88 | | - --mount=type=bind,src=requirements/cpu-build.txt,target=requirements/build.txt \ |
89 | | - uv pip install -r requirements/build.txt |
90 | | - |
91 | | -COPY . . |
92 | | -RUN --mount=type=bind,source=.git,target=.git \ |
93 | | - if [ "$GIT_REPO_CHECK" != 0 ]; then bash tools/check_repo.sh ; fi |
94 | | - |
95 | | -RUN --mount=type=cache,target=/root/.cache/uv \ |
96 | | - --mount=type=cache,target=/root/.cache/ccache \ |
97 | | - --mount=type=cache,target=/workspace/vllm/.deps,sharing=locked \ |
98 | | - --mount=type=bind,source=.git,target=.git \ |
99 | | - VLLM_TARGET_DEVICE=cpu python3 setup.py bdist_wheel |
100 | | - |
101 | | -######################### RELEASE IMAGE ######################### |
102 | | -FROM base AS vllm-openai |
103 | | - |
104 | | -WORKDIR /workspace/ |
105 | | - |
106 | | -RUN --mount=type=cache,target=/root/.cache/uv \ |
107 | | - --mount=type=cache,target=/root/.cache/ccache \ |
108 | | - --mount=type=bind,from=vllm-build,src=/workspace/vllm/dist,target=dist \ |
109 | | - uv pip install dist/*.whl |
110 | | - |
111 | | -ENTRYPOINT ["python3", "-m", "vllm.entrypoints.openai.api_server"] |
| 27 | +# Start the server directly from main.py |
| 28 | +ENTRYPOINT ["python3", "-u", "main.py"] |
0 commit comments