From f18daa7eeeed8a2da38bab1cd41ea190670b7ba7 Mon Sep 17 00:00:00 2001 From: f0reachARR Date: Thu, 22 Feb 2024 15:12:07 +0900 Subject: [PATCH] Bake arm64 image with mimic-cross --- .github/workflows/Docker.yaml | 28 +++++------------------ Dockerfile.arm64 | 43 +++++++++++++++++++++++++++++++++++ docker-bake.hcl | 15 ++++++++---- 3 files changed, 60 insertions(+), 26 deletions(-) create mode 100644 Dockerfile.arm64 diff --git a/.github/workflows/Docker.yaml b/.github/workflows/Docker.yaml index f50690fc8e2..9c42e07b21d 100644 --- a/.github/workflows/Docker.yaml +++ b/.github/workflows/Docker.yaml @@ -6,12 +6,12 @@ on: - cron: 0 0 * * * pull_request: paths: - - '**' - - '!docs/**' - - '!README.md' - - '!.github/**' - - '.github/workflows/Docker.yaml' - - '!mkdocs.yml' + - "**" + - "!docs/**" + - "!README.md" + - "!.github/**" + - ".github/workflows/Docker.yaml" + - "!mkdocs.yml" push: branches: - master @@ -62,19 +62,3 @@ jobs: push: ${{ github.event_name != 'pull_request' }} targets: | ${{ matrix.rosdistro }} - set: | - *.platform=linux/amd64 - - - name: Build and push (arm64) - uses: docker/bake-action@v3 - if: ${{ matrix.runs_on == 'macos-14'}} - with: - files: | - ./docker-bake.hcl - workdir: . - no-cache: true - push: ${{ github.event_name != 'pull_request' }} - targets: | - ${{ matrix.rosdistro }} - set: | - *.platform=linux/arm64/v8 diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 00000000000..8c4daa18210 --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,43 @@ +ARG ROS_DISTRO="humble" + +FROM --platform=${BUILDPLATFORM} impactaky/mc-ubuntu22.04-${TARGETARCH}-host:2.0.1 AS mimic-host +FROM ros:${ROS_DISTRO} as build-stage + +SHELL ["/bin/bash", "-c"] +ENV DEBIAN_FRONTEND=noninteractive +ENV DEBCONF_NOWARNINGS=yes + +COPY --from=mimic-host / /mimic-cross +RUN /mimic-cross/mimic-cross.deno/setup.sh + +RUN sudo apt-get update && sudo apt-get -y install python3-pip python3-rospkg python3-rosdep software-properties-common ccache +# cspell: ignore kisak +RUN add-apt-repository ppa:kisak/kisak-mesa -y +RUN apt-get update && apt-get install libegl-mesa0 -y + +WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator +COPY . $WORKDIR + +WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws/ +RUN mkdir -p /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator/external +WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws/src/scenario_simulator +RUN vcs import external < dependency_${ROS_DISTRO}.repos +WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws/src +RUN source /opt/ros/${ROS_DISTRO}/setup.bash && rosdep install -iy --from-paths . --rosdistro ${ROS_DISTRO} + +WORKDIR /home/ubuntu/Desktop/scenario_simulator_ws + +ENV CC="/usr/lib/ccache/gcc" +ENV CXX="/usr/lib/ccache/g++" +ENV CCACHE_DIR="/ccache" +RUN --mount=type=cache,target=/ccache source /opt/ros/${ROS_DISTRO}/setup.bash && \ + colcon build --symlink-install \ + --cmake-args \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DBUILD_CPP_MOCK_SCENARIOS=ON +COPY ./docker-entrypoint.sh / +RUN chmod a+x /docker-entrypoint.sh + +ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/docker-bake.hcl b/docker-bake.hcl index e44c8f02961..9a533f986ee 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -5,14 +5,21 @@ group "default" { target "base" { target = "build-stage" dockerfile = "Dockerfile" - platforms = ["linux/amd64", "linux/arm64/v8"] + platforms = ["linux/amd64"] +} + +target "base_arm64" { + dockerfile = "Dockerfile.arm64" + platforms = ["linux/arm64/v8"] } target "humble" { - inherits = ["base"] - name = "humble" + inherits = [base] + name = "humble-${base}" tags = ["ghcr.io/tier4/scenario_simulator_v2:humble"] args = {"ROS_DISTRO" : "humble"} group = ["humble"] - matrix = {} + matrix = { + base = ["base", "base_arm64"] + } }