Skip to content

Commit 11bb55d

Browse files
committed
Draft: [Infra] Split docker image for each usage
- Use docker buildx build for multi-platform support (linux/arm/v7, linux/arm64) - Image for cross build - Image for gbs build - Image for linting Additionally, remove useless package. ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
1 parent b92ccf1 commit 11bb55d

File tree

13 files changed

+426
-202
lines changed

13 files changed

+426
-202
lines changed

.github/workflows/build-dev-docker.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
name: Build docker image for CI/CD infra and publish to Docker Hub
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
# Use github action for build and push test image to docker hub
7+
build-docker-image:
8+
if: github.repository_owner == 'Samsung'
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
version: [ 'android-sdk', 'focal', 'jammy', 'noble', 'gbs', 'focal-cross', 'jammy-cross', 'noble-cross', 'lint' ]
13+
include:
14+
- version: 'focal-cross'
15+
platform-add: 'linux/arm64'
16+
- version: 'jammy-cross'
17+
platform-add: 'linux/arm64'
18+
- version: 'noble-cross'
19+
platform-add: 'linux/arm64'
20+
fail-fast: false
21+
22+
steps:
23+
- name: Login to DockerHub
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKER_USERNAME }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v3
31+
32+
- name: Install Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Build Docker Image
36+
uses: docker/build-push-action@v6
37+
with:
38+
file: ./infra/docker/${{ matrix.version }}/Dockerfile
39+
push: true
40+
tags: nnfw/one-devtools:${{ matrix.version }}-test
41+
platforms: linux/amd64${{ matrix.platform-add }}
42+
cache-from: type=gha
43+
cache-to: type=gha,mode=max
44+
45+
test-cross-image:
46+
if: github.repository_owner == 'Samsung'
47+
needs: build-docker-image
48+
strategy:
49+
matrix:
50+
# TODO: noble (not supported rootfs yet)
51+
ubuntu_code: [ 'focal', 'jammy']
52+
fail-fast: false
53+
runs-on: one-x64-linux
54+
container:
55+
image: nnfw/one-devtools:${{ matrix.ubuntu_code }}-cross-test
56+
options: --user root
57+
env:
58+
TARGET_ARCH: armv7l
59+
BUILD_TYPE: release
60+
CROSS_BUILD: 1
61+
OPTIONS: "-DBUILD_ARMCOMPUTE=OFF" # Disable arm compute library
62+
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
67+
- name: Caching externals
68+
uses: actions/cache@v4
69+
with:
70+
path: externals
71+
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}-${{ hashFiles('infra/nnfw/cmake/packages/**/*.cmake') }}
72+
restore-keys: |
73+
external-onert-${{ matrix.ubuntu_code }}-
74+
external-onert-
75+
external-
76+
77+
- name: Download rootfs for cross build
78+
uses: dawidd6/action-download-artifact@v7
79+
with:
80+
workflow: generate-rootfs.yml
81+
branch: master
82+
name: rootfs_arm_${{ matrix.ubuntu_code }}
83+
84+
# Workaround: symlink for rootfs checker in cmake toolchain file
85+
- name: Install rootfs for cross build and build
86+
run: |
87+
mkdir -p tools/cross/rootfs
88+
tar -zxf rootfs_arm_${{ matrix.ubuntu_code }}.tar.gz -C tools/cross/rootfs
89+
pushd tools/cross/rootfs/arm
90+
ln -sf usr/lib lib
91+
popd
92+
make -f Makefile.template
93+
94+
test-x64-image:
95+
if: github.repository_owner == 'Samsung'
96+
needs: build-docker-image
97+
strategy:
98+
matrix:
99+
ubuntu_code: [ 'focal', 'jammy', 'noble' ]
100+
fail-fast: false
101+
runs-on: one-x64-linux
102+
container:
103+
image: nnfw/one-devtools:${{ matrix.ubuntu_code }}-test
104+
options: --user root
105+
env:
106+
BUILD_TYPE: release
107+
108+
steps:
109+
- name: Checkout
110+
uses: actions/checkout@v4
111+
112+
- name: Caching externals
113+
uses: actions/cache@v4
114+
with:
115+
path: externals
116+
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}-${{ hashFiles('infra/nnfw/cmake/packages/**/*.cmake') }}
117+
restore-keys: |
118+
external-onert-${{ matrix.ubuntu_code }}-
119+
external-onert-
120+
external-
121+
122+
- name: Build
123+
run: make -f Makefile.template
124+
125+
test-android-sdk-image:
126+
if: github.repository_owner == 'Samsung'
127+
needs: build-docker-image
128+
runs-on: one-x64-linux
129+
container:
130+
image: nnfw/one-devtools:android-sdk-test
131+
options: --user root
132+
env:
133+
BUILD_TYPE: release
134+
CROSS_BUILD: 1
135+
TARGET_OS: android
136+
137+
steps:
138+
- name: Checkout
139+
uses: actions/checkout@v4
140+
141+
- name: Caching externals
142+
uses: actions/cache@v4
143+
with:
144+
path: externals
145+
key: external-onert-ndk-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}-${{ hashFiles('infra/nnfw/cmake/packages/**/*.cmake') }}
146+
restore-keys: |
147+
external-onert-ndk-
148+
external-onert-
149+
external-
150+
151+
- name: Build onert
152+
run: make -f Makefile.template
153+
154+
test-arm64-image:
155+
if: github.repository_owner == 'Samsung'
156+
needs: build-docker-image
157+
strategy:
158+
matrix:
159+
ubuntu_code: [ 'focal', 'jammy', 'noble' ]
160+
fail-fast: false
161+
runs-on: one-arm-linux
162+
container:
163+
image: nnfw/one-devtools:focal-cross-test
164+
options: --user root
165+
env:
166+
BUILD_TYPE: release
167+
CROSS_BUILD: 1
168+
TARGET_ARCH: aarch64
169+
OPTIONS: "-DBUILD_ARMCOMPUTE=OFF" # Disable arm compute library
170+
171+
steps:
172+
- name: Checkout
173+
uses: actions/checkout@v4
174+
175+
- name: Caching externals
176+
uses: actions/cache@v4
177+
with:
178+
path: externals
179+
key: external-onert-${{ matrix.ubuntu_code }}-${{ hashFiles('infra/cmake/packages/**/*.cmake') }}-${{ hashFiles('infra/nnfw/cmake/packages/**/*.cmake') }}
180+
restore-keys: |
181+
external-onert-${{ matrix.ubuntu_code }}-
182+
external-onert-
183+
external-
184+
185+
- name: Build onert
186+
run: |
187+
make -f Makefile.template
188+
189+
# Don't test gbs, lint image - not used on CI/CD
190+
191+
publish-image:
192+
if: github.repository_owner == 'Samsung'
193+
needs: test-cross-image, test-x64-image, test-android-sdk-image, test-arm64-image
194+
strategy:
195+
matrix:
196+
version: [ 'android-sdk', 'focal', 'jammy', 'noble', 'gbs', 'focal-cross', 'jammy-cross', 'noble-cross', 'lint' ]
197+
include:
198+
- version: 'focal-cross'
199+
platform-add: 'linux/arm64'
200+
- version: 'jammy-cross'
201+
platform-add: 'linux/arm64'
202+
- version: 'noble-cross'
203+
platform-add: 'linux/arm64'
204+
fail-fast: false
205+
runs-on: ubuntu-latest
206+
steps:
207+
- name: Login to DockerHub
208+
uses: docker/login-action@v3
209+
with:
210+
username: ${{ secrets.DOCKER_USERNAME }}
211+
password: ${{ secrets.DOCKER_PASSWORD }}
212+
213+
- name: Set up QEMU
214+
uses: docker/setup-qemu-action@v3
215+
216+
- name: Install Docker Buildx
217+
uses: docker/setup-buildx-action@v3
218+
219+
- name: Build Docker Image
220+
uses: docker/build-push-action@v6
221+
with:
222+
file: ./infra/docker/${{ matrix.version }}/Dockerfile
223+
push: true
224+
tags: nnfw/one-devtools:${{ matrix.version }}
225+
platforms: linux/amd64${{ matrix.platform-add }}
226+
cache-from: type=gha
227+
cache-to: type=gha,mode=max
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build docker build for CI/CD infra PR Test
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
paths:
7+
- '.github/workflows/build-test-dev-docker.yml'
8+
- 'infra/docker/**'
9+
10+
# Cancel previous running jobs when pull request is updated
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
# We cannot test multi-platform test on PR, so we only test amd64
16+
jobs:
17+
# Build on docker CLI for PR test without login
18+
build-pr-test:
19+
if: github.repository_owner == 'Samsung'
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
version: [ 'android-sdk', 'focal', 'jammy', 'noble', 'gbs', 'focal-cross', 'jammy-cross', 'noble-cross', 'lint' ]
24+
include:
25+
- version: 'focal-cross'
26+
ubuntu_code: 'focal'
27+
- version: 'jammy-cross'
28+
ubuntu_code: 'jammy'
29+
# TODO: noble
30+
fail-fast: false
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Build Docker Image
36+
run: |
37+
docker build --tag one-test --load --file infra/docker/${{ matrix.version }}/Dockerfile .
38+
39+
- name: Test onert native build
40+
if: matrix.version == 'focal' || matrix.version == 'jammy' || matrix.version == 'noble'
41+
env:
42+
DOCKER_IMAGE_NAME: one-test
43+
run: |
44+
./nnas docker-run --user make -f Makefile.template
45+
./nnas docker-run --user Product/out/test/onert-test unittest
46+
47+
- name: Download rootfs for cross build
48+
# TODO noble-cross
49+
if: matrix.version == 'focal-cross' || matrix.version == 'jammy-cross'
50+
uses: dawidd6/action-download-artifact@v7
51+
with:
52+
workflow: generate-rootfs.yml
53+
branch: master
54+
name: rootfs_arm_${{ matrix.ubuntu_code }}
55+
56+
# Workaround: symlink for rootfs checker in cmake toolchain file
57+
- name: Install rootfs for cross build and build
58+
if: matrix.version == 'focal-cross' || matrix.version == 'jammy-cross'
59+
env:
60+
DOCKER_IMAGE_NAME: one-test
61+
DOCKER_ENV_VARS: '-e CROSS_BUILD=1 -e TARGET_ARCH=armv7l'
62+
run: |
63+
mkdir -p tools/cross/rootfs
64+
tar -zxf rootfs_arm_${{ matrix.ubuntu_code }}.tar.gz -C tools/cross/rootfs
65+
pushd tools/cross/rootfs/${{ matrix.platform }}
66+
ln -sf usr/lib lib
67+
popd
68+
./nnas docker-run --user make -f Makefile.template
69+
70+
- name: Test android build
71+
if: matrix.version == 'android-sdk'
72+
env:
73+
DOCKER_IMAGE_NAME: one-test
74+
DOCKER_ENV_VARS: '-e CROSS_BUILD=1 -e TARGET_OS=android'
75+
run: |
76+
./nnas docker-run --user make -f Makefile.template

infra/command/build-docker-image

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function Usage()
88
echo " --codename ubuntu codename, default: ${UBUNTU_CODENAME}"
99
echo " default image name is nnfw/one-devtools:[codename]"
1010
echo "Options can use as docker build option:"
11-
docker build --help
11+
docker buildx build --help
1212
}
1313

1414
DOCKER_FILE_RPATH_BASE="infra/docker"
@@ -45,14 +45,9 @@ done
4545
DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-nnfw/one-devtools:$UBUNTU_CODENAME}
4646
DOCKER_FILE_RPATH=$DOCKER_FILE_RPATH_BASE/$UBUNTU_CODENAME/Dockerfile
4747

48-
HOST_ARCH=$(uname -m)
49-
if [[ -n $HOST_ARCH && $HOST_ARCH != "x86_64" ]]; then
50-
DOCKER_FILE_RPATH=$DOCKER_FILE_RPATH.$HOST_ARCH
51-
fi
52-
5348
DOCKER_BUILD_ARGS+=("-t ${DOCKER_IMAGE_NAME}")
5449

55-
docker build --build-arg http_proxy="${http_proxy}" \
50+
docker buildx build --build-arg http_proxy="${http_proxy}" \
5651
--build-arg https_proxy="${https_proxy}" \
5752
${DOCKER_BUILD_ARGS[@]} \
5853
- < ${NNAS_PROJECT_PATH}/${DOCKER_FILE_RPATH}

0 commit comments

Comments
 (0)