From 774e2b1bcabfb9d02d0e47e747f423a0feb11768 Mon Sep 17 00:00:00 2001 From: Hyeongseok Oh Date: Tue, 1 Apr 2025 18:46:49 +0900 Subject: [PATCH] [infra/docker] Introduce docker image for cross build This commit introduces Dockerfiles to support cross-compilation toolchain environment to split with native build environment Dockerfile. ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh --- .github/workflows/build-dev-docker.yml | 47 +++++++++++++++++++++++-- infra/docker/focal-cross/Dockerfile | 48 ++++++++++++++++++++++++++ infra/docker/jammy-cross/Dockerfile | 48 ++++++++++++++++++++++++++ infra/docker/noble-cross/Dockerfile | 47 +++++++++++++++++++++++++ 4 files changed, 187 insertions(+), 3 deletions(-) create mode 100644 infra/docker/focal-cross/Dockerfile create mode 100644 infra/docker/jammy-cross/Dockerfile create mode 100644 infra/docker/noble-cross/Dockerfile diff --git a/.github/workflows/build-dev-docker.yml b/.github/workflows/build-dev-docker.yml index 399fa53b268..cb847fb05b1 100644 --- a/.github/workflows/build-dev-docker.yml +++ b/.github/workflows/build-dev-docker.yml @@ -19,6 +19,7 @@ jobs: yml: ${{ steps.filter.outputs.yml }} android: ${{ steps.filter.outputs.android }} ubuntu: ${{ steps.filter.outputs.ubuntu }} + ubuntu-cross: ${{ steps.filter.outputs.ubuntu-cross }} steps: - uses: dorny/paths-filter@v3 id: filter @@ -29,9 +30,14 @@ jobs: - 'infra/docker/android-sdk/**' ubuntu: - '.github/**' - - 'infra/docker/focal/**' - - 'infra/docker/jammy/**' - - 'infra/docker/noble/**' + - 'infra/docker/focal/Dockerfile' + - 'infra/docker/jammy/Dockerfile' + - 'infra/docker/noble/Dockerfile' + ubuntu-cross: + - '.github/**' + - 'infra/docker/focal-cross/Dockerfile' + - 'infra/docker/jammy-cross/Dockerfile' + - 'infra/docker/noble-cross/Dockerfile' # Build on docker CLI for PR test without login build-ubuntu: @@ -56,6 +62,41 @@ jobs: ./nnas docker-run --user make -f Makefile.template ./nnas docker-run --user Product/out/test/onert-test unittest + build-ubuntu-cross: + needs: filtering + if: github.repository_owner == 'Samsung' && needs.filtering.outputs.ubuntu-cross == 'true' + runs-on: one-x64-linux + strategy: + matrix: + version: [ 'focal', 'jammy', 'noble' ] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build Docker Image + run: | + docker build --file infra/docker/${{ matrix.version }}-cross/Dockerfile --tag one-test . + + - name: Download rootfs for cross build + uses: dawidd6/action-download-artifact@v7 + with: + workflow: generate-rootfs.yml + branch: master + name: rootfs_arm_${{ matrix.version }} + + # Workaround: symlink for rootfs checker in cmake toolchain file + - name: Install rootfs and cross build + env: + DOCKER_IMAGE_NAME: one-test + DOCKER_ENV_VARS: '-e CROSS_BUILD=1 -e TARGET_ARCH=armv7l' + run: | + mkdir -p tools/cross/rootfs + tar -zxf rootfs_arm_${{ matrix.version }}.tar.gz -C tools/cross/rootfs + pushd tools/cross/rootfs/arm + ln -sf usr/lib lib + popd + ./nnas docker-run --user make -f Makefile.template + build-android: needs: filtering if: github.repository_owner == 'Samsung' && needs.filtering.outputs.android == 'true' diff --git a/infra/docker/focal-cross/Dockerfile b/infra/docker/focal-cross/Dockerfile new file mode 100644 index 00000000000..4fee8cc04e3 --- /dev/null +++ b/infra/docker/focal-cross/Dockerfile @@ -0,0 +1,48 @@ +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:focal + +# Install tzdata without user input +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -qqy install tzdata + +# Build tool +RUN apt-get update && apt-get -qqy install build-essential cmake scons git lcov g++-arm-linux-gnueabihf g++-aarch64-linux-gnu + +# Debian build tool +RUN apt-get update && apt-get -qqy install fakeroot devscripts debhelper python3-all dh-python + +# Install extra dependencies +RUN apt-get update && apt-get -qqy install libboost-all-dev libgflags-dev libgoogle-glog-dev libatlas-base-dev libhdf5-dev + +# Additonal tools +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get -qqy install wget zip unzip python3 python3-pip python3-venv python3-dev curl +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install numpy flatbuffers + +# Setup user to match host user, and give superuser permissions +ARG USER_ID=1000 +ARG GROUP_ID=${USER_ID} +RUN apt-get update && apt-get -qqy install sudo +RUN addgroup --gid ${GROUP_ID} ubuntu && adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} ubuntu && usermod -aG sudo ubuntu +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +RUN echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# Clean archives (to reduce image size) +RUN apt-get clean -y + +# Set user to the one we just created +USER ${USER_ID} diff --git a/infra/docker/jammy-cross/Dockerfile b/infra/docker/jammy-cross/Dockerfile new file mode 100644 index 00000000000..d17df639ed0 --- /dev/null +++ b/infra/docker/jammy-cross/Dockerfile @@ -0,0 +1,48 @@ +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:jammy + +# Install tzdata without user input +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -qqy install tzdata + +# Build tool +RUN apt-get update && apt-get -qqy install build-essential cmake scons git lcov g++-arm-linux-gnueabihf g++-aarch64-linux-gnu + +# Debian build tool +RUN apt-get update && apt-get -qqy install fakeroot devscripts debhelper python3-all dh-python + +# Install extra dependencies +RUN apt-get update && apt-get -qqy install libboost-all-dev libgflags-dev libgoogle-glog-dev libatlas-base-dev libhdf5-dev + +# Additonal tools +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get -qqy install wget zip unzip python3 python3-pip python3-venv python3-dev curl +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install numpy flatbuffers + +# Setup user to match host user, and give superuser permissions +ARG USER_ID=1000 +ARG GROUP_ID=${USER_ID} +RUN apt-get update && apt-get -qqy install sudo +RUN addgroup --gid ${GROUP_ID} ubuntu && adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} ubuntu && usermod -aG sudo ubuntu +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +RUN echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# Clean archives (to reduce image size) +RUN apt-get clean -y + +# Set user to the one we just created +USER ${USER_ID} diff --git a/infra/docker/noble-cross/Dockerfile b/infra/docker/noble-cross/Dockerfile new file mode 100644 index 00000000000..485b4218d8d --- /dev/null +++ b/infra/docker/noble-cross/Dockerfile @@ -0,0 +1,47 @@ +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:noble + +# Install tzdata without user input +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -qqy install tzdata + +# Build tool +RUN apt-get update && apt-get -qqy install build-essential cmake scons git lcov g++-arm-linux-gnueabihf g++-aarch64-linux-gnu + +# Debian build tool +RUN apt-get update && apt-get -qqy install fakeroot devscripts debhelper python3-all dh-python + +# Install extra dependencies +RUN apt-get update && apt-get -qqy install libboost-all-dev libgflags-dev libgoogle-glog-dev libatlas-base-dev libhdf5-dev + +# Additonal tools +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive \ + apt-get -qqy install wget zip unzip python3 python3-pip python3-venv python3-dev curl +RUN python3 -m pip install numpy flatbuffers --break-system-packages + +# Setup user ubuntu: give superuser permissions without password +RUN apt-get update && apt-get -qqy install sudo +RUN usermod -aG sudo ubuntu +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# Clean archives (to reduce image size) +RUN apt-get clean -y + +# Set user to ubuntu(1000) +USER ubuntu +WORKDIR /home/ubuntu +RUN python3 -m venv ~/.local +ENV PATH=~/.local/bin:$PATH