|
| 1 | +# Copyright 2026 FlagOS Contributors |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +ARG METAX_BASE_IMAGE=harbor.baai.ac.cn/flagos-dev/vllm-plugin-fl:vllm-metax-0.20.0-maca.ai3.7.0.107-torch2.8-py312-ubuntu22.04-amd64 |
| 16 | + |
| 17 | +# ---------- base stage ---------- |
| 18 | +FROM ${METAX_BASE_IMAGE} AS base |
| 19 | + |
| 20 | +ARG METAX_BASE_IMAGE |
| 21 | +ARG VLLM_VERSION=0.20.2 |
| 22 | +ARG FLAGGEMS_REF=3123859968915e361e8452dd796dc6b27c956324 |
| 23 | +ARG BUILD_DATE=unknown |
| 24 | +ARG VCS_REF=unknown |
| 25 | +ARG IMAGE_VERSION=unknown |
| 26 | +ARG IMAGE_STAGE=dev |
| 27 | +ARG SOURCE_URL=https://github.com/flagos-ai/vllm-plugin-FL |
| 28 | + |
| 29 | +LABEL org.opencontainers.image.title="vllm-plugin-fl" \ |
| 30 | + org.opencontainers.image.description="MetaX CI image for vllm-plugin-FL" \ |
| 31 | + org.opencontainers.image.source="${SOURCE_URL}" \ |
| 32 | + org.opencontainers.image.created="${BUILD_DATE}" \ |
| 33 | + org.opencontainers.image.revision="${VCS_REF}" \ |
| 34 | + org.opencontainers.image.version="${IMAGE_VERSION}" \ |
| 35 | + org.opencontainers.image.base.name="${METAX_BASE_IMAGE}" \ |
| 36 | + io.flagos.accelerator.backend="metax" \ |
| 37 | + io.flagos.image.stage="${IMAGE_STAGE}" \ |
| 38 | + io.flagos.vllm.version="${VLLM_VERSION}" \ |
| 39 | + io.flagos.flaggems.revision="${FLAGGEMS_REF}" |
| 40 | + |
| 41 | +ENV DEBIAN_FRONTEND=noninteractive \ |
| 42 | + GEMS_VENDOR=metax \ |
| 43 | + VLLM_PLUGINS=fl \ |
| 44 | + PATH="/opt/conda/bin:${PATH}" |
| 45 | + |
| 46 | +# actions/checkout requires git before any platform setup script runs. Build |
| 47 | +# tools are installed here because both vLLM empty mode and FlagGems are fixed |
| 48 | +# parts of the MetaX runtime rather than per-job CI dependencies. |
| 49 | +RUN apt-get update \ |
| 50 | + && apt-get install -y --no-install-recommends \ |
| 51 | + build-essential \ |
| 52 | + ca-certificates \ |
| 53 | + curl \ |
| 54 | + git \ |
| 55 | + && rm -rf /var/lib/apt/lists/* |
| 56 | + |
| 57 | +RUN python -m pip install --no-cache-dir \ |
| 58 | + wheel \ |
| 59 | + setuptools-scm \ |
| 60 | + scikit-build-core==0.11 \ |
| 61 | + pybind11 \ |
| 62 | + ninja \ |
| 63 | + cmake |
| 64 | + |
| 65 | +# Replace the vLLM Python package from the vendor image with official vLLM in |
| 66 | +# empty mode. The MetaX kernels and torch runtime remain provided by the base |
| 67 | +# image. Install non-editably so /workspace mounts cannot hide the package. |
| 68 | +RUN python -m pip uninstall -y vllm || true; \ |
| 69 | + python -m pip cache remove vllm || true; \ |
| 70 | + SITE_PACKAGES="$(python -c 'import site; print(site.getsitepackages()[0])')"; \ |
| 71 | + find "${SITE_PACKAGES}" -maxdepth 1 \ |
| 72 | + \( -name "vllm" -o -name "vllm-*.dist-info" -o -name "vllm-*.egg-info" \) \ |
| 73 | + -exec rm -rf {} + 2>/dev/null || true; \ |
| 74 | + rm -rf /tmp/vllm \ |
| 75 | + && git clone --depth 1 --branch "v${VLLM_VERSION}" \ |
| 76 | + https://github.com/vllm-project/vllm.git /tmp/vllm \ |
| 77 | + && VLLM_TARGET_DEVICE=empty python -m pip install --no-cache-dir \ |
| 78 | + --no-build-isolation --no-deps /tmp/vllm \ |
| 79 | + && rm -rf /tmp/vllm |
| 80 | + |
| 81 | +# FlagGems is pinned to the source revision already validated on MetaX C550. |
| 82 | +RUN rm -rf /tmp/FlagGems \ |
| 83 | + && rm -f /tmp/FlagGems.tar.gz \ |
| 84 | + && mkdir -p /tmp/FlagGems \ |
| 85 | + && curl --fail --location --retry 5 --retry-all-errors \ |
| 86 | + --retry-delay 5 --connect-timeout 30 --max-time 1200 \ |
| 87 | + "https://codeload.github.com/FlagOpen/FlagGems/tar.gz/${FLAGGEMS_REF}" \ |
| 88 | + --output /tmp/FlagGems.tar.gz \ |
| 89 | + && tar -xzf /tmp/FlagGems.tar.gz --strip-components=1 -C /tmp/FlagGems \ |
| 90 | + && python -m pip install --no-cache-dir \ |
| 91 | + -r /tmp/FlagGems/requirements/requirements_metax.txt \ |
| 92 | + && GEMS_VENDOR=metax python -m pip install --no-cache-dir \ |
| 93 | + --no-build-isolation /tmp/FlagGems \ |
| 94 | + && rm -rf /tmp/FlagGems /tmp/FlagGems.tar.gz \ |
| 95 | + && python -m pip install --no-cache-dir \ |
| 96 | + numpy==1.26.4 \ |
| 97 | + opencv-python-headless==4.11.0.86 \ |
| 98 | + outlines-core==0.2.14 |
| 99 | + |
| 100 | +WORKDIR /workspace |
| 101 | + |
| 102 | +# ---------- dev stage ---------- |
| 103 | +FROM base AS dev |
| 104 | + |
| 105 | +RUN python -m pip install --no-cache-dir \ |
| 106 | + pytest \ |
| 107 | + pytest-cov \ |
| 108 | + pytest-timeout \ |
| 109 | + pytest-json-report \ |
| 110 | + pre-commit \ |
| 111 | + ruff |
| 112 | + |
| 113 | +WORKDIR /workspace |
| 114 | + |
| 115 | +# ---------- ci stage ---------- |
| 116 | +FROM base AS ci |
| 117 | + |
| 118 | +# Keep project-independent CI dependencies in the image. setup.sh only needs |
| 119 | +# to install the checked-out vllm-plugin-FL package. |
| 120 | +RUN python -m pip install --no-cache-dir \ |
| 121 | + pytest \ |
| 122 | + pytest-cov \ |
| 123 | + pytest-timeout \ |
| 124 | + pytest-json-report \ |
| 125 | + requests \ |
| 126 | + openai \ |
| 127 | + decorator \ |
| 128 | + pyyaml \ |
| 129 | + sqlalchemy \ |
| 130 | + "modelscope>=1.18.1" |
| 131 | + |
| 132 | +WORKDIR /workspace |
| 133 | + |
| 134 | +# ---------- release stage ---------- |
| 135 | +FROM base AS release |
| 136 | + |
| 137 | +WORKDIR /workspace |
0 commit comments