Skip to content

Commit 8bd6077

Browse files
committed
Add container image build ci
Signed-off-by: Yikun Jiang <yikunkero@gmail.com>
1 parent b88443b commit 8bd6077

File tree

2 files changed

+142
-3
lines changed

2 files changed

+142
-3
lines changed

.github/workflows/image.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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 }}

Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
# limitations under the License.
1616
#
1717

18-
FROM quay.io/ascend/cann:8.0.rc3.beta1-910b-ubuntu22.04-py3.10
18+
FROM quay.io/ascend/cann:8.0.0.beta1-910b-ubuntu22.04-py3.10
1919

2020
# Define environments
2121
ENV DEBIAN_FRONTEND=noninteractive
2222

2323
RUN apt-get update -y && \
24-
apt-get install -y python3-pip git vim
24+
apt-get install -y python3-pip git vim && \
25+
rm -rf /var/cache/apt/* && \
26+
rm -rf /var/lib/apt/lists/*
2527

2628
WORKDIR /workspace
2729

@@ -35,6 +37,9 @@ RUN git clone --depth 1 $VLLM_REPO /workspace/vllm
3537
RUN VLLM_TARGET_DEVICE="empty" python3 -m pip install /workspace/vllm/
3638

3739
# Install vllm-ascend main
38-
RUN python3 -m pip install /workspace/vllm-ascend/
40+
RUN python3 -m pip install /workspace/vllm-ascend/ -f https://download.pytorch.org/whl/torch/
41+
42+
# Install modelscope
43+
RUN python3 -m pip install modelscope
3944

4045
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)