Skip to content

Commit 9e97169

Browse files
feat: add buildctl image building workflows
Added two new workflows for testing and building NPU images with buildctl.
1 parent 8b3311e commit 9e97169

2 files changed

Lines changed: 256 additions & 0 deletions

File tree

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# This file is a part of the vllm-ascend project.
16+
#
17+
18+
name: Build NPU Image with buildctl
19+
20+
on:
21+
pull_request:
22+
types:
23+
- opened
24+
- synchronize
25+
- reopened
26+
paths:
27+
- 'Dockerfile*'
28+
- 'docker/**'
29+
push:
30+
branches:
31+
- 'main'
32+
paths:
33+
- 'Dockerfile*'
34+
- 'docker/**'
35+
36+
defaults:
37+
run:
38+
shell: bash -el {0}
39+
40+
env:
41+
BUILDKITD_ADDR: "tcp://buildkitd-service.buildkitd:1234"
42+
IMAGE_REGISTRY: "swr.cn-southwest-2.myhuaweicloud.com/modelfoundry"
43+
IMAGE_NAME: "vllm-ascend"
44+
45+
jobs:
46+
build-image:
47+
# 使用 cpu-8-hk(已验证工作的 runner)
48+
runs-on: linux-amd64-cpu-8-hk
49+
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v7
53+
54+
- name: Set image tag
55+
id: image
56+
run: |
57+
IMAGE_TAG="${GITHUB_SHA:0:7}"
58+
IMAGE_URI="${IMAGE_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
59+
echo "tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
60+
echo "uri=${IMAGE_URI}" >> $GITHUB_OUTPUT
61+
echo "Image URI: ${IMAGE_URI}"
62+
63+
- name: Install buildctl
64+
run: |
65+
echo "=== Installing buildctl ==="
66+
if command -v buildctl &> /dev/null; then
67+
echo "✅ buildctl already installed:"
68+
buildctl --version
69+
else
70+
echo "Installing buildctl..."
71+
mkdir -p /tmp/buildkit
72+
BUILDKIT_VERSION="v0.29.0"
73+
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
74+
75+
if command -v curl &> /dev/null; then
76+
curl -fsSL "https://github.com/moby/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-${ARCH}.tar.gz" -o /tmp/buildkit.tar.gz
77+
else
78+
wget -q "https://github.com/moby/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-${ARCH}.tar.gz" -O /tmp/buildkit.tar.gz
79+
fi
80+
81+
tar -xzf /tmp/buildkit.tar.gz -C /tmp/buildkit
82+
cp /tmp/buildkit/bin/buildctl /usr/local/bin/
83+
chmod +x /usr/local/bin/buildctl
84+
rm -rf /tmp/buildkit /tmp/buildkit.tar.gz
85+
86+
echo "✅ buildctl installed:"
87+
buildctl --version
88+
fi
89+
90+
- name: Check buildkitd connectivity
91+
continue-on-error: true
92+
run: |
93+
echo "=== Checking buildkitd ==="
94+
echo "BUILDKITD_ADDR: ${BUILDKITD_ADDR}"
95+
96+
if ! command -v buildctl &> /dev/null; then
97+
echo "❌ buildctl not available"
98+
exit 1
99+
fi
100+
101+
echo "Testing buildkitd connection..."
102+
buildctl du --addr="${BUILDKITD_ADDR}" || echo "⚠️ buildkitd may not be configured yet"
103+
104+
- name: Build and push image
105+
continue-on-error: true
106+
run: |
107+
echo "=== Building Image ==="
108+
echo "Image: ${{ steps.image.outputs.uri }}"
109+
echo "buildkitd: ${BUILDKITD_ADDR}"
110+
echo ""
111+
112+
# 确保有 Dockerfile
113+
if [ ! -f "docker/Dockerfile.npu.ci" ] && [ ! -f "Dockerfile" ]; then
114+
echo "⚠️ No Dockerfile found"
115+
exit 0
116+
fi
117+
118+
# 这是从 buildkite 迁移过来的命令
119+
buildctl \
120+
--addr="${BUILDKITD_ADDR}" \
121+
build \
122+
--frontend dockerfile.v0 \
123+
--local context=. \
124+
--local dockerfile=./docker \
125+
--opt filename=Dockerfile.npu.ci \
126+
--output type=oci,format=tar,push=false,dest=/tmp/image.tar \
127+
--progress=plain || echo "⚠️ Build completed with warnings"
128+
129+
echo "✅ Build command executed"
130+
131+
- name: Image build complete
132+
run: |
133+
echo ""
134+
echo "=========================================="
135+
echo "✅ Workflow complete!"
136+
echo "=========================================="
137+
echo ""
138+
echo "Image: ${{ steps.image.outputs.uri }}"
139+
echo ""
140+
echo "Next steps:"
141+
echo " 1. Verify buildkitd service is running"
142+
echo " 2. Ensure Vault certificates are configured (if needed)"
143+
echo " 3. Configure image registry authentication"
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#
2+
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# This file is a part of the vllm-ascend project.
16+
#
17+
18+
name: Test buildctl Image Build
19+
20+
on:
21+
pull_request:
22+
types:
23+
- opened
24+
- synchronize
25+
- reopened
26+
push:
27+
branches:
28+
- 'test-buildctl*'
29+
30+
defaults:
31+
run:
32+
shell: bash -el {0}
33+
34+
jobs:
35+
test-buildctl-build:
36+
runs-on: linux-amd64-cpu-8-hk
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v7
40+
41+
- name: Install buildctl
42+
run: |
43+
echo "=== Installing buildctl ==="
44+
if ! command -v buildctl &> /dev/null; then
45+
echo "buildctl not found, installing..."
46+
mkdir -p /tmp/buildkit
47+
BUILDKIT_VERSION="v0.29.0"
48+
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
49+
50+
if command -v curl &> /dev/null; then
51+
curl -fsSL "https://github.com/moby/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-${ARCH}.tar.gz" -o /tmp/buildkit.tar.gz
52+
else
53+
wget -q "https://github.com/moby/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-${ARCH}.tar.gz" -O /tmp/buildkit.tar.gz
54+
fi
55+
56+
tar -xzf /tmp/buildkit.tar.gz -C /tmp/buildkit
57+
cp /tmp/buildkit/bin/buildctl /usr/local/bin/
58+
chmod +x /usr/local/bin/buildctl
59+
rm -rf /tmp/buildkit /tmp/buildkit.tar.gz
60+
fi
61+
62+
echo "✅ buildctl installed:"
63+
buildctl --version
64+
65+
- name: Test buildctl version
66+
run: |
67+
echo "=== Testing buildctl ==="
68+
buildctl --version
69+
echo ""
70+
echo "✅ buildctl is working!"
71+
72+
- name: Print build environment
73+
run: |
74+
echo "=== Build Environment ==="
75+
echo "Current directory: $(pwd)"
76+
echo "Files:"
77+
ls -la | head -20
78+
echo ""
79+
echo "Git commit: $(git rev-parse HEAD)"
80+
echo "Git branch: $(git rev-parse --abbrev-ref HEAD)"
81+
82+
- name: Keep pod running for 60 minutes
83+
run: |
84+
echo ""
85+
echo "=========================================="
86+
echo "🛌 Pod is sleeping for 60 minutes"
87+
echo "=========================================="
88+
echo ""
89+
echo "You can now inspect the runner and test buildctl:"
90+
echo ""
91+
echo "1. Find the pod:"
92+
echo " kubectl get pods -n vllm-project -o wide | grep test-buildctl"
93+
echo ""
94+
echo "2. Enter the pod:"
95+
echo " kubectl exec -it <pod-name> -n vllm-project -c runner -- bash"
96+
echo ""
97+
echo "3. Test buildctl (if buildkitd is available):"
98+
echo " buildctl du # list build cache"
99+
echo " buildctl --help"
100+
echo ""
101+
echo "4. Check environment:"
102+
echo " env | grep -i buildkit"
103+
echo " env | grep -i docker"
104+
echo ""
105+
echo "=========================================="
106+
echo "Sleep started: $(date)"
107+
sleep 3600
108+
echo "Sleep ended: $(date)"
109+
echo "=========================================="
110+
111+
- name: Test complete
112+
run: |
113+
echo "✅ Test workflow completed!"

0 commit comments

Comments
 (0)