1+ # Base UBI image for s390x architecture
2+ ARG BASE_UBI_IMAGE_TAG=9.5-1736404155
3+ ARG PYTHON_VERSION=3.12
4+ FROM registry.access.redhat.com/ubi9/ubi-minimal:${BASE_UBI_IMAGE_TAG} AS base
5+
6+ # Install basic dependencies
7+ ARG PYTHON_VERSION
8+ ENV PYTHON_VERSION=${PYTHON_VERSION}
9+
10+ WORKDIR /workspace
11+
12+ ENV LANG=C.UTF-8 \
13+ LC_ALL=C.UTF-8
14+
15+ # Install development utilities
16+ RUN microdnf install -y \
17+ which procps findutils tar vim git gcc gcc-gfortran g++ make patch zlib-devel \
18+ libjpeg-turbo-devel libtiff-devel libpng-devel libwebp-devel freetype-devel harfbuzz-devel \
19+ openssl-devel openblas openblas-devel autoconf automake libtool cmake && \
20+ microdnf clean all
21+
22+ # Python Installation
23+ FROM base AS python-install
24+ ARG PYTHON_VERSION
25+
26+ ENV VIRTUAL_ENV=/opt/vllm
27+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
28+ ENV PYTHON_VERSION=${PYTHON_VERSION}
29+ RUN microdnf install -y \
30+ python${PYTHON_VERSION}-devel python${PYTHON_VERSION}-pip python${PYTHON_VERSION}-wheel && \
31+ python${PYTHON_VERSION} -m venv $VIRTUAL_ENV && pip install --no-cache -U pip wheel uv && microdnf clean all
32+
33+ FROM python-install AS pyarrow
34+
35+ # Build Apache Arrow
36+ WORKDIR /tmp
37+ RUN --mount=type=cache,target=/root/.cache/uv \
38+ git clone https://github.com/apache/arrow.git && \
39+ cd arrow/cpp && \
40+ mkdir release && cd release && \
41+ cmake -DCMAKE_BUILD_TYPE=Release \
42+ -DCMAKE_INSTALL_PREFIX=/usr/local \
43+ -DARROW_PYTHON=ON \
44+ -DARROW_PARQUET=ON \
45+ -DARROW_ORC=ON \
46+ -DARROW_FILESYSTEM=ON \
47+ -DARROW_WITH_LZ4=ON \
48+ -DARROW_WITH_ZSTD=ON \
49+ -DARROW_WITH_SNAPPY=ON \
50+ -DARROW_JSON=ON \
51+ -DARROW_CSV=ON \
52+ -DARROW_DATASET=ON \
53+ -DPROTOBUF_PROTOC_EXECUTABLE=/usr/bin/protoc \
54+ -DARROW_DEPENDENCY_SOURCE=BUNDLED \
55+ .. && \
56+ make -j$(nproc) && \
57+ make install && \
58+ cd ../../python && \
59+ export PYARROW_PARALLEL=4 && \
60+ export ARROW_BUILD_TYPE=release && \
61+ uv pip install -r requirements-build.txt && \
62+ python setup.py build_ext --build-type=$ARROW_BUILD_TYPE --bundle-arrow-cpp bdist_wheel
63+
64+ FROM python-install AS numa-build
65+ # Install numactl (needed for numa.h dependency)
66+ WORKDIR /tmp
67+ RUN curl -LO https://github.com/numactl/numactl/archive/refs/tags/v2.0.16.tar.gz && \
68+ tar -xvzf v2.0.16.tar.gz && \
69+ cd numactl-2.0.16 && \
70+ ./autogen.sh && \
71+ ./configure && \
72+ make
73+
74+ # Set include path
75+ ENV C_INCLUDE_PATH="/usr/local/include:$C_INCLUDE_PATH"
76+
77+ FROM python-install AS rust
78+ ENV CARGO_HOME=/root/.cargo
79+ ENV RUSTUP_HOME=/root/.rustup
80+ ENV PATH="$CARGO_HOME/bin:$RUSTUP_HOME/bin:$PATH"
81+
82+ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
83+ . "$CARGO_HOME/env" && \
84+ rustup default stable && \
85+ rustup show
86+
87+ FROM python-install AS torch-vision
88+ # Install torchvision
89+ ARG TORCH_VERSION=2.7.0.dev20250304
90+ ARG TORCH_VISION_VERSION=v0.20.1
91+ WORKDIR /tmp
92+ RUN --mount=type=cache,target=/root/.cache/uv \
93+ git clone https://github.com/pytorch/vision.git && \
94+ cd vision && \
95+ git checkout $TORCH_VISION_VERSION && \
96+ uv pip install -v torch==${TORCH_VERSION} --extra-index-url https://download.pytorch.org/whl/nightly/cpu && \
97+ python setup.py bdist_wheel
98+
99+ # Final build stage
100+ FROM python-install AS vllm-cpu
101+ ARG PYTHON_VERSION
102+
103+ # Set correct library path for torch and numactl
104+ ENV LD_LIBRARY_PATH="/opt/vllm/lib64/python${PYTHON_VERSION}/site-packages/torch/lib:/usr/local/lib:$LD_LIBRARY_PATH"
105+ ENV C_INCLUDE_PATH="/usr/local/include:$C_INCLUDE_PATH"
106+ ENV UV_LINK_MODE=copy
107+ ENV CARGO_HOME=/root/.cargo
108+ ENV RUSTUP_HOME=/root/.rustup
109+ ENV PATH="$CARGO_HOME/bin:$RUSTUP_HOME/bin:$PATH"
110+
111+ COPY . /workspace/vllm
112+ WORKDIR /workspace/vllm
113+
114+ RUN --mount=type=bind,from=numa-build,src=/tmp/numactl-2.0.16,target=/numactl \
115+ make -C /numactl install
116+
117+ # Install dependencies, including PyTorch and Apache Arrow
118+ RUN --mount=type=cache,target=/root/.cache/uv \
119+ --mount=type=bind,from=rust,source=/root/.cargo,target=/root/.cargo,rw \
120+ --mount=type=bind,from=rust,source=/root/.rustup,target=/root/.rustup,rw \
121+ --mount=type=bind,from=pyarrow,source=/tmp/arrow/python/dist,target=/tmp/arrow-wheels \
122+ --mount=type=bind,from=torch-vision,source=/tmp/vision/dist,target=/tmp/vision-wheels/ \
123+ sed -i '/^torch/d' requirements-build.txt && \
124+ ARROW_WHL_FILE=$(ls /tmp/arrow-wheels/pyarrow-*.whl | head -n 1) && \
125+ VISION_WHL_FILE=$(ls /tmp/vision-wheels/*.whl | head -n 1) && \
126+ uv pip install -v \
127+ $ARROW_WHL_FILE \
128+ $VISION_WHL_FILE \
129+ --extra-index-url https://download.pytorch.org/whl/nightly/cpu \
130+ --index-strategy unsafe-best-match \
131+ -r requirements-build.txt \
132+ -r requirements-cpu.txt
133+
134+ # Build and install vllm
135+ RUN --mount=type=cache,target=/root/.cache/uv \
136+ VLLM_TARGET_DEVICE=cpu python setup.py bdist_wheel && \
137+ uv pip install "$(echo dist/*.whl)[tensorizer]"
138+
139+ # setup non-root user for vllm
140+ RUN umask 002 && \
141+ useradd --uid 2000 --gid 0 vllm && \
142+ mkdir -p /home/vllm && \
143+ chmod g+rwx /home/vllm
144+
145+ COPY LICENSE /licenses/vllm.md
146+ COPY examples/*.jinja /app/data/template/
147+
148+ USER 2000
149+ WORKDIR /home/vllm
150+
151+ # Set the default entrypoint
152+ ENTRYPOINT ["python", "-m", "vllm.entrypoints.openai.api_server"]
0 commit comments