Skip to content

Commit 8fd782c

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

File tree

2 files changed

+114
-3
lines changed

2 files changed

+114
-3
lines changed

.github/workflows/image.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: 'image'
2+
# This is a docker build check and publish job:
3+
# 1. PR Triggered docker image build check
4+
# - is for image build check
5+
# - Enable on main/*-dev branch
6+
# - push: ${{ github.event_name != 'pull_request' }} ==> false
7+
# 2. branches push trigger image publish
8+
# - is for branch/dev/nightly image
9+
# - commits are merge into main/*-dev ==> vllm-ascend:main / vllm-ascend:*-dev
10+
# 3. tags push trigger image publish
11+
# - is for final release image
12+
# - Publish when tag with v* (pep440 version) ===> vllm-ascend:v1.2.3|latest / vllm-ascend:v1.2.3rc1
13+
on:
14+
pull_request:
15+
branches:
16+
- 'main'
17+
- '*-dev'
18+
paths:
19+
- '.github/workflows/image.yml'
20+
- 'Dockerfile'
21+
- 'vllm_ascend/**'
22+
push:
23+
# Publish image when tagging, the Dockerfile in tag will be build as tag image
24+
branches:
25+
- 'main'
26+
- '*-dev'
27+
tags:
28+
- 'v*'
29+
paths:
30+
- '.github/workflows/image.yml'
31+
- 'Dockerfile'
32+
- 'vllm_ascend/**'
33+
jobs:
34+
35+
build:
36+
name: vllm-ascend image
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Prepare
43+
run: |
44+
REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
45+
echo "REPO_OWNER=${REPO_OWNER}" >> "$GITHUB_ENV"
46+
47+
- name: Print
48+
run: |
49+
echo "REPO_OWNER:""${REPO_OWNER}"
50+
51+
- name: Docker meta
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
# TODO(yikun): add more hub image and a note on release policy for container image
56+
# The REPO_OWNER will be:
57+
# - `vllm-project` in usptream repo
58+
# - lowercase github user in your fork repo
59+
images: |
60+
ghcr.io/${{ env.REPO_OWNER }}/vllm-ascend
61+
# Note for test case
62+
# https://github.com/marketplace/actions/docker-metadata-action#typeref
63+
# 1. branch job pulish per main/*-dev branch commits
64+
# 2. main and dev pull_request is build only, so the tag pr-N is fine
65+
# 3. only pep440 matched tag will be published:
66+
# - v0.7.1 --> v0.7.1, latest
67+
# - pre/post/dev: v0.7.1rc1/v0.7.1rc1/v0.7.1rc1.dev1/v0.7.1.post1, no latest
68+
# which follow the rule from vLLM with prefix v
69+
# TODO(yikun): the post release might be considered as latest release
70+
tags: |
71+
type=ref,event=branch
72+
type=ref,event=pr
73+
type=pep440,pattern={{raw}}
74+
75+
- name: Free up disk space
76+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
77+
with:
78+
tool-cache: true
79+
docker-images: false
80+
81+
- name: Build - Set up QEMU
82+
uses: docker/setup-qemu-action@v2
83+
# TODO(yikun): remove this after https://github.com/docker/setup-qemu-action/issues/198 resolved
84+
with:
85+
image: tonistiigi/binfmt:qemu-v7.0.0-28
86+
87+
- name: Build - Set up Docker Buildx
88+
uses: docker/setup-buildx-action@v2
89+
90+
- name: Publish - Login to GitHub Container Registry
91+
uses: docker/login-action@v2
92+
with:
93+
registry: ghcr.io
94+
username: ${{ github.actor }}
95+
password: ${{ secrets.GITHUB_TOKEN }}
96+
97+
- name: Build and push
98+
uses: docker/build-push-action@v6
99+
with:
100+
platforms: linux/amd64,linux/arm64
101+
cache-from: type=gha
102+
cache-to: type=gha,mode=max
103+
# only trigger when tag, branch/main push
104+
push: ${{ github.event_name != 'pull_request' }}
105+
labels: ${{ steps.meta.outputs.labels }}
106+
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)