Skip to content

Commit 7f855c6

Browse files
authored
Merge pull request #105 from cosmo-wander-ai/codex/rockchip-build-env
build(rockchip): share builder across RKNN targets
2 parents 40ac11e + 7ebf556 commit 7f855c6

27 files changed

Lines changed: 1180 additions & 260 deletions

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
/build_cpu
66
/build_cpu_verify
77
/build_cpu_windows
8+
/build_rknn
89
/cmake-build-*
10+
/docs/.vitepress/dist
11+
/3rd/srs-*/trunk/objs
912
/node_modules
1013
/src/web/node_modules
1114
/src/web/dist

.github/workflows/ci-build-rk3576.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
name: Rockchip Cross Build
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.dockerignore'
7+
- '.github/workflows/ci-build-rockchip.yml'
8+
- 'Dockerfile.rockchip'
9+
- 'Dockerfile.rockchip.dockerignore'
10+
- 'Dockerfile.rk3576'
11+
- 'docker-compose.rockchip.yml'
12+
- 'docker-compose.rk3576.yml'
13+
- 'config/rknn/**'
14+
- 'config/rockchip-build/**'
15+
- 'config/rockchip-media/**'
16+
- 'cmake/**'
17+
- 'data/resource/aiboxresource_rknn/**'
18+
- 'scripts/**'
19+
- 'src/**'
20+
- 'test/**'
21+
- 'tools/rknn/**'
22+
- 'CMakeLists.txt'
23+
push:
24+
branches: [main]
25+
paths:
26+
- '.dockerignore'
27+
- '.github/workflows/ci-build-rockchip.yml'
28+
- 'Dockerfile.rockchip'
29+
- 'Dockerfile.rockchip.dockerignore'
30+
- 'Dockerfile.rk3576'
31+
- 'docker-compose.rockchip.yml'
32+
- 'docker-compose.rk3576.yml'
33+
- 'config/rknn/platforms/**'
34+
- 'config/rockchip-build/**'
35+
- 'config/rockchip-media/**'
36+
- 'scripts/install_rkllm_sdk.py'
37+
- 'tools/rknn/media_sysroot_lock.py'
38+
schedule:
39+
# Run daily at 02:12 Beijing Time (18:12 UTC on the previous day).
40+
- cron: '12 18 * * *'
41+
workflow_dispatch:
42+
workflow_call:
43+
44+
permissions:
45+
contents: read
46+
47+
concurrency:
48+
group: ${{ github.workflow }}-${{ github.ref }}
49+
cancel-in-progress: true
50+
51+
jobs:
52+
package:
53+
name: rockchip-package (${{ matrix.chip }})
54+
runs-on: ubuntu-latest
55+
timeout-minutes: 120
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
include:
60+
- chip: rk3576
61+
models: include
62+
- chip: rv1126b
63+
models: preserve
64+
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v7
68+
with:
69+
submodules: recursive
70+
71+
- name: Validate Rockchip package policy tooling
72+
run: |
73+
bash -n scripts/build_rknn.sh scripts/build_rockchip_package.sh
74+
python3 -m unittest discover -s test -p 'test_package_profile.py'
75+
python3 -m unittest discover -s test/agent \
76+
-p 'test_rknn_media_sysroot_lock.py'
77+
78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
81+
- name: Build locked Rockchip builder
82+
uses: docker/build-push-action@v6
83+
with:
84+
context: .
85+
file: Dockerfile.rockchip
86+
target: rockchip-builder
87+
platforms: linux/amd64
88+
load: true
89+
tags: cosmo-edge-build-env-rockchip:ci
90+
provenance: false
91+
cache-from: type=gha,scope=rockchip-builder-${{ matrix.chip }}
92+
cache-to: type=gha,mode=max,scope=rockchip-builder-${{ matrix.chip }}
93+
94+
- name: Validate shared Compose entry
95+
env:
96+
COSMO_ROCKCHIP_BUILDER_IMAGE: cosmo-edge-build-env-rockchip:ci
97+
COSMO_TARGET_CHIP: ${{ matrix.chip }}
98+
COSMO_PACKAGE_MODELS: ${{ matrix.models }}
99+
run: docker compose -f docker-compose.rockchip.yml config --quiet
100+
101+
- name: Build target package and tests
102+
env:
103+
COSMO_ROCKCHIP_BUILDER_IMAGE: cosmo-edge-build-env-rockchip:ci
104+
COSMO_TARGET_CHIP: ${{ matrix.chip }}
105+
COSMO_PACKAGE_MODELS: ${{ matrix.models }}
106+
run: docker compose -f docker-compose.rockchip.yml run --rm cosmo-rockchip-package
107+
108+
- name: Verify target artifacts
109+
env:
110+
CHIP: ${{ matrix.chip }}
111+
run: |
112+
set -euo pipefail
113+
shopt -s nullglob
114+
packages=("build_output/${CHIP}"/cosmo-*.tar.gz)
115+
if (( ${#packages[@]} != 1 )) || [[ ! -f "${packages[0]:-}" || -L "${packages[0]:-}" ]]; then
116+
echo "Expected exactly one regular ${CHIP} package artifact." >&2
117+
exit 1
118+
fi
119+
package="${packages[0]}"
120+
package_name="${package##*/}"
121+
digest="$(sha256sum -- "$package")"
122+
digest="${digest%% *}"
123+
printf '%s %s\n' "$digest" "$package_name" | tee "${CHIP}-package.sha256"
124+
cmp -s <(printf '%s\n' "$CHIP") "build_output/${CHIP}/TARGET_CHIP"
125+
(cd "build_output/${CHIP}" && sha256sum -c SHA256SUMS)
126+
for binary in build_rknn/cosmo-tests build_rknn/cosmo-rknn-backend-smoke build_rknn/cosmo-rknn-fastpath-qualify; do
127+
binary_info="$(file "$binary")"
128+
printf '%s\n' "$binary_info"
129+
grep -Fq 'ARM aarch64' <<< "$binary_info"
130+
done
131+
printf "## %s candidate\n\n- Package: \`%s\`\n- SHA-256: \`%s\`\n" \
132+
"$CHIP" "$package_name" "$digest" >> "$GITHUB_STEP_SUMMARY"
133+
134+
- name: Upload target candidate
135+
uses: actions/upload-artifact@v7
136+
with:
137+
name: ${{ matrix.chip }}-candidate-${{ github.sha }}
138+
path: |
139+
build_output/${{ matrix.chip }}/*.tar.gz
140+
build_output/${{ matrix.chip }}/TARGET_CHIP
141+
build_output/${{ matrix.chip }}/MEDIA_RUNTIME_PROFILE
142+
build_output/${{ matrix.chip }}/SHA256SUMS
143+
${{ matrix.chip }}-package.sha256
144+
build_rknn/cosmo-tests
145+
build_rknn/cosmo-rknn-backend-smoke
146+
build_rknn/cosmo-rknn-fastpath-qualify
147+
if-no-files-found: error
148+
overwrite: true
149+
retention-days: 7
150+
151+
publish-builder:
152+
name: publish-rockchip-builder
153+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
154+
needs: package
155+
runs-on: ubuntu-latest
156+
timeout-minutes: 60
157+
permissions:
158+
contents: read
159+
packages: write
160+
161+
steps:
162+
- name: Checkout code
163+
uses: actions/checkout@v7
164+
165+
- name: Set up Docker Buildx
166+
uses: docker/setup-buildx-action@v3
167+
168+
- name: Log in to GHCR
169+
uses: docker/login-action@v3
170+
with:
171+
registry: ghcr.io
172+
username: ${{ github.actor }}
173+
password: ${{ secrets.GITHUB_TOKEN }}
174+
175+
- name: Define immutable and stable tags
176+
id: metadata
177+
uses: docker/metadata-action@v5
178+
with:
179+
images: ghcr.io/cosmo-wander-ai/cosmo_edge-build-env_rockchip
180+
tags: |
181+
type=sha,format=long
182+
type=raw,value=v1,enable={{is_default_branch}}
183+
184+
- name: Publish locked Rockchip builder
185+
id: publish
186+
uses: docker/build-push-action@v6
187+
with:
188+
context: .
189+
file: Dockerfile.rockchip
190+
target: rockchip-builder
191+
platforms: linux/amd64
192+
push: true
193+
tags: ${{ steps.metadata.outputs.tags }}
194+
labels: ${{ steps.metadata.outputs.labels }}
195+
provenance: false
196+
cache-from: type=gha,scope=rockchip-builder-publish
197+
cache-to: type=gha,mode=max,scope=rockchip-builder-publish
198+
199+
- name: Record published digest
200+
env:
201+
PUBLISHED_DIGEST: ${{ steps.publish.outputs.digest }}
202+
run: |
203+
printf "## Shared Rockchip builder\n\n- Digest: \`%s\`\n" \
204+
"$PUBLISHED_DIGEST" >> "$GITHUB_STEP_SUMMARY"

Dockerfile.rk3576

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
FROM ghcr.io/cosmo-wander-ai/cosmo_edge-build-env_rk3576@sha256:0dbb35f5a4336777c311b5f881886cd9b284371d61ceffff55a8216c01d2b076
1+
# syntax=docker/dockerfile:1.7
22

3-
LABEL org.opencontainers.image.title="CosmoEdge RK3576 build environment"
4-
LABEL org.opencontainers.image.description="Pinned RKNN/MPP/RGA builder extended with Rockchip RKLLM Runtime v1.3.0"
5-
LABEL org.opencontainers.image.source="https://github.com/cosmo-wander-ai/cosmo-edge"
6-
LABEL org.opencontainers.image.rkllm.version="1.3.0"
7-
LABEL org.opencontainers.image.rkllm.revision="878f9361fd3afa7e167b7079918918f78d2c1c2a"
3+
# Deprecated compatibility shim. Build and publish the shared image from
4+
# Dockerfile.rockchip; this file intentionally contains no chip-specific SDK
5+
# installation logic.
6+
ARG ROCKCHIP_BUILDER_IMAGE=ghcr.io/cosmo-wander-ai/cosmo_edge-build-env_rockchip@sha256:0810c23042cbe86d3a1c91f848b9849a34d94222f3ad7b7418913a26da19e71b
7+
FROM ${ROCKCHIP_BUILDER_IMAGE}
88

9-
COPY scripts/install_rkllm_sdk.py /tmp/install_rkllm_sdk.py
10-
RUN python3 -I -B /tmp/install_rkllm_sdk.py --root /opt/rkllm \
11-
&& rm -f /tmp/install_rkllm_sdk.py \
12-
&& test -f /opt/rkllm/include/rkllm.h \
13-
&& test -f /opt/rkllm/lib/librkllmrt.so \
14-
&& test -f /opt/rkllm/LICENSE
9+
LABEL io.cosmo.compatibility.entry="Dockerfile.rk3576" \
10+
io.cosmo.compatibility.replacement="Dockerfile.rockchip"

0 commit comments

Comments
 (0)