|
| 1 | +name: 'image' |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - 'main' |
| 7 | + - '*-dev' |
| 8 | + paths: |
| 9 | + - '.github/workflows/build_image.yml' |
| 10 | + - '.github/workflows/publish_image.yml' |
| 11 | + - '.github/workflows/image.yml' |
| 12 | + - 'Dockerfile' |
| 13 | + - 'vllm_ascend/**' |
| 14 | + push: |
| 15 | + # Publish image when tagging, the Dockerfile in tag will be build as tag image |
| 16 | + branches: |
| 17 | + - 'main' |
| 18 | + - '*-dev' |
| 19 | + tags: |
| 20 | + - 'v*' |
| 21 | + paths: |
| 22 | + - '.github/workflows/build_image.yml' |
| 23 | + - '.github/workflows/publish_image.yml' |
| 24 | + - '.github/workflows/image.yml' |
| 25 | + - 'Dockerfile' |
| 26 | + - 'vllm_ascend/**' |
| 27 | +jobs: |
| 28 | + |
| 29 | + build: |
| 30 | + name: vllm-ascend image |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Prepare |
| 37 | + run: | |
| 38 | + REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') |
| 39 | + echo "REPO_OWNER=${REPO_OWNER}" >> "$GITHUB_ENV" |
| 40 | +
|
| 41 | + - name: Print |
| 42 | + run: | |
| 43 | + echo "REPO_OWNER:""${REPO_OWNER}" |
| 44 | +
|
| 45 | + - name: Docker meta |
| 46 | + id: meta |
| 47 | + uses: docker/metadata-action@v5 |
| 48 | + with: |
| 49 | + # TODO(yikun): add more hub image and a note on release policy for container image |
| 50 | + # The REPO_OWNER will be: |
| 51 | + # - `vllm-project` in usptream repo |
| 52 | + # - lowercase github user in your fork repo |
| 53 | + images: | |
| 54 | + ghcr.io/${{ env.REPO_OWNER }}/vllm-ascend |
| 55 | + # Note for test case |
| 56 | + # https://github.com/marketplace/actions/docker-metadata-action#typeref |
| 57 | + # 1. branch job pulish per main/*-dev branch commits |
| 58 | + # 2. main and dev pull_request only build is unimportant |
| 59 | + # 3. only pep440 matched tag will be published: |
| 60 | + # - v0.7.1 --> v0.7.1, latest |
| 61 | + # - pre/post/dev: v0.7.1rc1/v0.7.1rc1/v0.7.1rc1.dev1/v0.7.1.post1, no latest |
| 62 | + # (follow the rule from vLLM with prefix v) |
| 63 | + # TODO(yikun): the post release might be considered as latest release |
| 64 | + tags: | |
| 65 | + type=ref,event=branch |
| 66 | + type=ref,event=pr |
| 67 | + type=pep440,pattern={{raw}} |
| 68 | +
|
| 69 | + - name: Free up disk space |
| 70 | + run: | |
| 71 | + # Copy from https://github.com/apache/spark/blob/d6ad7798a9f77b611edb8d9f8648f726fcaa6938/dev/free_disk_space |
| 72 | + # It's a work around for Github Action "No space left on device" |
| 73 | + echo "==================================" |
| 74 | + echo "Free up disk space on CI system" |
| 75 | + echo "==================================" |
| 76 | + |
| 77 | + echo "Listing top 100 largest packages (from large to small)" |
| 78 | + printf "Installed-Size\tPackage\n" |
| 79 | + dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n -r | head -n 100 |
| 80 | + df -h |
| 81 | + |
| 82 | + echo "Removing large packages" |
| 83 | + sudo rm -rf /usr/share/dotnet/ |
| 84 | + sudo rm -rf /usr/share/php/ |
| 85 | + sudo rm -rf /usr/local/graalvm/ |
| 86 | + sudo rm -rf /usr/local/.ghcup/ |
| 87 | + sudo rm -rf /usr/local/share/powershell |
| 88 | + sudo rm -rf /usr/local/share/chromium |
| 89 | + sudo rm -rf /usr/local/lib/android |
| 90 | + sudo rm -rf /usr/local/lib/node_modules |
| 91 | +
|
| 92 | + sudo rm -rf /opt/az |
| 93 | + sudo rm -rf /opt/hostedtoolcache/CodeQL |
| 94 | + sudo rm -rf /opt/hostedtoolcache/go |
| 95 | + sudo rm -rf /opt/hostedtoolcache/node |
| 96 | +
|
| 97 | + sudo apt-get remove --purge -y '^aspnet.*' |
| 98 | + sudo apt-get remove --purge -y '^dotnet-.*' |
| 99 | + sudo apt-get remove --purge -y '^llvm-.*' |
| 100 | + sudo apt-get remove --purge -y 'php.*' |
| 101 | + sudo apt-get remove --purge -y '^mongodb-.*' |
| 102 | + sudo apt-get remove --purge -y snapd google-chrome-stable microsoft-edge-stable firefox |
| 103 | + sudo apt-get remove --purge -y azure-cli google-cloud-sdk mono-devel powershell libgl1-mesa-dri |
| 104 | + sudo apt-get autoremove --purge -y |
| 105 | + sudo apt-get clean |
| 106 | +
|
| 107 | + df -h |
| 108 | +
|
| 109 | + - name: Build - Set up QEMU |
| 110 | + uses: docker/setup-qemu-action@v2 |
| 111 | + # TODO(yikun): remove this after https://github.com/docker/setup-qemu-action/issues/198 resolved |
| 112 | + with: |
| 113 | + image: tonistiigi/binfmt:qemu-v7.0.0-28 |
| 114 | + |
| 115 | + - name: Build - Set up Docker Buildx |
| 116 | + uses: docker/setup-buildx-action@v2 |
| 117 | + |
| 118 | + - name: Publish - Login to GitHub Container Registry |
| 119 | + uses: docker/login-action@v2 |
| 120 | + with: |
| 121 | + registry: ghcr.io |
| 122 | + username: ${{ github.actor }} |
| 123 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 124 | + |
| 125 | + - name: Build and push |
| 126 | + uses: docker/build-push-action@v6 |
| 127 | + with: |
| 128 | + platforms: linux/amd64,linux/arm64 |
| 129 | + cache-from: type=gha |
| 130 | + cache-to: type=gha,mode=max |
| 131 | + # only trigger when tag, branch/main push |
| 132 | + push: ${{ github.event_name != 'pull_request' }} |
| 133 | + labels: ${{ steps.meta.outputs.labels }} |
| 134 | + tags: ${{ steps.meta.outputs.tags }} |
0 commit comments