From cb4d23c04fbdfd96bd9a8d3cff44602275eff319 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Wed, 15 May 2024 16:52:30 +0900 Subject: [PATCH 01/10] cache apt archives --- .github/workflows/vcs-import.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/vcs-import.yaml b/.github/workflows/vcs-import.yaml index 235c2b19df3..7d1c7973e63 100644 --- a/.github/workflows/vcs-import.yaml +++ b/.github/workflows/vcs-import.yaml @@ -16,6 +16,13 @@ jobs: - name: Check out repository uses: actions/checkout@v4 + - name: Cache apt archives + uses: actions/cache@v3 + with: + path: | + /var/cache/apt + /var/lib/apt + - name: Install pip for rosdep run: | sudo apt-get -y update From 3d3d7435bdca7d5743dfd70bf1c7c5ccf7769ae7 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Wed, 15 May 2024 17:12:04 +0900 Subject: [PATCH 02/10] set key Signed-off-by: Yutaka Kondo --- .github/workflows/vcs-import.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/vcs-import.yaml b/.github/workflows/vcs-import.yaml index 7d1c7973e63..739f2bac183 100644 --- a/.github/workflows/vcs-import.yaml +++ b/.github/workflows/vcs-import.yaml @@ -22,6 +22,9 @@ jobs: path: | /var/cache/apt /var/lib/apt + key: apt-${{ runner.os }}-${{ github.ref_name }} + restore-keys: | + apt- - name: Install pip for rosdep run: | From 6726f4e4391351f646cc3ab7af51e5929640e7dc Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Wed, 15 May 2024 17:14:25 +0900 Subject: [PATCH 03/10] refine restore-keys Signed-off-by: Yutaka Kondo --- .github/workflows/vcs-import.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vcs-import.yaml b/.github/workflows/vcs-import.yaml index 739f2bac183..57cb35728a3 100644 --- a/.github/workflows/vcs-import.yaml +++ b/.github/workflows/vcs-import.yaml @@ -24,7 +24,7 @@ jobs: /var/lib/apt key: apt-${{ runner.os }}-${{ github.ref_name }} restore-keys: | - apt- + apt-${{ runner.os }}- - name: Install pip for rosdep run: | From ead6ad9c9f0790480fea2678d87c80925a62726d Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Mon, 27 May 2024 10:00:30 +0900 Subject: [PATCH 04/10] remove actions/cache --- .github/workflows/vcs-import.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/vcs-import.yaml b/.github/workflows/vcs-import.yaml index 57cb35728a3..235c2b19df3 100644 --- a/.github/workflows/vcs-import.yaml +++ b/.github/workflows/vcs-import.yaml @@ -16,16 +16,6 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - - name: Cache apt archives - uses: actions/cache@v3 - with: - path: | - /var/cache/apt - /var/lib/apt - key: apt-${{ runner.os }}-${{ github.ref_name }} - restore-keys: | - apt-${{ runner.os }}- - - name: Install pip for rosdep run: | sudo apt-get -y update From f72d2b8daf174d84a2231d567a22b27e21c940e8 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Mon, 27 May 2024 10:02:50 +0900 Subject: [PATCH 05/10] mount apt cache Signed-off-by: Yutaka Kondo --- docker/autoware-openadk/Dockerfile | 46 +++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/docker/autoware-openadk/Dockerfile b/docker/autoware-openadk/Dockerfile index 4d0cd0d31b0..2b7e204bf2e 100644 --- a/docker/autoware-openadk/Dockerfile +++ b/docker/autoware-openadk/Dockerfile @@ -6,10 +6,14 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG ROS_DISTRO # Install apt packages and add GitHub to known hosts for private repositories -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ +RUN rm -f /etc/apt/apt.conf.d/docker-clean \ + && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ gosu \ ssh \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache \ + && apt-get autoremove -y && rm -rf "$HOME"/.cache \ && mkdir -p ~/.ssh \ && ssh-keyscan github.com >> ~/.ssh/known_hosts @@ -19,10 +23,12 @@ COPY ansible/ /autoware/ansible/ WORKDIR /autoware # Set up base environment -RUN --mount=type=ssh \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=ssh \ ./setup-dev-env.sh -y --module base --runtime openadk \ && pip uninstall -y ansible ansible-core \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache \ + && apt-get autoremove -y && rm -rf "$HOME"/.cache \ && echo "source /opt/ros/${ROS_DISTRO}/setup.bash" > /etc/bash.bashrc # Create entrypoint @@ -37,10 +43,14 @@ COPY setup-dev-env.sh ansible-galaxy-requirements.yaml amd64.env arm64.env /auto COPY ansible/ /autoware/ansible/ WORKDIR /autoware -RUN --mount=type=ssh \ +RUN rm -f /etc/apt/apt.conf.d/docker-clean \ + && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=ssh \ ./setup-dev-env.sh -y rosdep \ && pip uninstall -y ansible ansible-core \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache + && apt-get autoremove -y && rm -rf "$HOME"/.cache # Copy repository files COPY src /autoware/src @@ -71,20 +81,24 @@ ENV CXX="/usr/lib/ccache/g++" # cspell: ignore libcu libnv # Set up development environment -RUN --mount=type=ssh \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=ssh \ ./setup-dev-env.sh -y --module all ${SETUP_ARGS} --no-cuda-drivers openadk \ && pip uninstall -y ansible ansible-core \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache \ + && apt-get autoremove -y && rm -rf "$HOME"/.cache \ && find / -name 'libcu*.a' -delete \ && find / -name 'libnv*.a' -delete # Install rosdep dependencies COPY --from=src-imported /rosdep-all-depend-packages.txt /tmp/rosdep-all-depend-packages.txt # hadolint ignore=SC2002 -RUN --mount=type=ssh \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=ssh \ apt-get update \ && cat /tmp/rosdep-all-depend-packages.txt | xargs apt-get install -y --no-install-recommends \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache + && apt-get autoremove -y && rm -rf "$HOME"/.cache # Build Autoware COPY --from=src-imported /autoware/src /autoware/src @@ -104,10 +118,12 @@ FROM prebuilt as devel SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Install development tools and artifacts -RUN --mount=type=ssh \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=ssh \ ./setup-dev-env.sh -y --module dev-tools openadk \ && pip uninstall -y ansible ansible-core \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache + && apt-get autoremove -y && rm -rf "$HOME"/.cache # Create entrypoint COPY docker/autoware-openadk/etc/ros_entrypoint.sh /ros_entrypoint.sh @@ -124,12 +140,14 @@ ARG SETUP_ARGS # Set up runtime environment and artifacts COPY --from=src-imported /rosdep-exec-depend-packages.txt /tmp/rosdep-exec-depend-packages.txt # hadolint ignore=SC2002 -RUN --mount=type=ssh \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + --mount=type=ssh \ ./setup-dev-env.sh -y --module all ${SETUP_ARGS} --no-cuda-drivers --runtime openadk \ && pip uninstall -y ansible ansible-core \ && apt-get update \ && cat /tmp/rosdep-exec-depend-packages.txt | xargs apt-get install -y --no-install-recommends \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache \ + && apt-get autoremove -y && rm -rf "$HOME"/.cache \ && find /usr/lib/$LIB_DIR-linux-gnu -name "*.a" -type f -delete \ && find / -name "*.o" -type f -delete \ && find / -name "*.h" -type f -delete \ From 5e993263698ae955e3d6f77aa30faa435c33ad5e Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Mon, 27 May 2024 10:06:30 +0900 Subject: [PATCH 06/10] reorder Signed-off-by: Yutaka Kondo --- docker/autoware-openadk/Dockerfile | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/docker/autoware-openadk/Dockerfile b/docker/autoware-openadk/Dockerfile index 2b7e204bf2e..3f735f90f9b 100644 --- a/docker/autoware-openadk/Dockerfile +++ b/docker/autoware-openadk/Dockerfile @@ -23,9 +23,9 @@ COPY ansible/ /autoware/ansible/ WORKDIR /autoware # Set up base environment -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ +RUN --mount=type=ssh \ + --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ - --mount=type=ssh \ ./setup-dev-env.sh -y --module base --runtime openadk \ && pip uninstall -y ansible ansible-core \ && apt-get autoremove -y && rm -rf "$HOME"/.cache \ @@ -45,9 +45,9 @@ WORKDIR /autoware RUN rm -f /etc/apt/apt.conf.d/docker-clean \ && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ +RUN --mount=type=ssh \ + --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ - --mount=type=ssh \ ./setup-dev-env.sh -y rosdep \ && pip uninstall -y ansible ansible-core \ && apt-get autoremove -y && rm -rf "$HOME"/.cache @@ -81,9 +81,9 @@ ENV CXX="/usr/lib/ccache/g++" # cspell: ignore libcu libnv # Set up development environment -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ +RUN --mount=type=ssh \ + --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ - --mount=type=ssh \ ./setup-dev-env.sh -y --module all ${SETUP_ARGS} --no-cuda-drivers openadk \ && pip uninstall -y ansible ansible-core \ && apt-get autoremove -y && rm -rf "$HOME"/.cache \ @@ -95,7 +95,6 @@ COPY --from=src-imported /rosdep-all-depend-packages.txt /tmp/rosdep-all-depend- # hadolint ignore=SC2002 RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ - --mount=type=ssh \ apt-get update \ && cat /tmp/rosdep-all-depend-packages.txt | xargs apt-get install -y --no-install-recommends \ && apt-get autoremove -y && rm -rf "$HOME"/.cache @@ -118,9 +117,9 @@ FROM prebuilt as devel SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Install development tools and artifacts -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ +RUN --mount=type=ssh \ + --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ - --mount=type=ssh \ ./setup-dev-env.sh -y --module dev-tools openadk \ && pip uninstall -y ansible ansible-core \ && apt-get autoremove -y && rm -rf "$HOME"/.cache @@ -140,9 +139,9 @@ ARG SETUP_ARGS # Set up runtime environment and artifacts COPY --from=src-imported /rosdep-exec-depend-packages.txt /tmp/rosdep-exec-depend-packages.txt # hadolint ignore=SC2002 -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ +RUN --mount=type=ssh \ + --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ - --mount=type=ssh \ ./setup-dev-env.sh -y --module all ${SETUP_ARGS} --no-cuda-drivers --runtime openadk \ && pip uninstall -y ansible ansible-core \ && apt-get update \ From b88fad01829c05bd43fc98b0a8cf89ca86952cba Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Mon, 27 May 2024 10:52:10 +0900 Subject: [PATCH 07/10] echo Signed-off-by: Yutaka Kondo --- docker/autoware-openadk/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/autoware-openadk/Dockerfile b/docker/autoware-openadk/Dockerfile index 3f735f90f9b..8f5754f4a6b 100644 --- a/docker/autoware-openadk/Dockerfile +++ b/docker/autoware-openadk/Dockerfile @@ -5,6 +5,8 @@ FROM $BASE_IMAGE as base SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG ROS_DISTRO +RUN echo "DO NOT MERGE" + # Install apt packages and add GitHub to known hosts for private repositories RUN rm -f /etc/apt/apt.conf.d/docker-clean \ && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache From 983458984df156cbed34d9867ab716fe10ae9267 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Mon, 27 May 2024 11:19:56 +0900 Subject: [PATCH 08/10] Revert "echo" This reverts commit b88fad01829c05bd43fc98b0a8cf89ca86952cba. --- docker/autoware-openadk/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/autoware-openadk/Dockerfile b/docker/autoware-openadk/Dockerfile index 8f5754f4a6b..3f735f90f9b 100644 --- a/docker/autoware-openadk/Dockerfile +++ b/docker/autoware-openadk/Dockerfile @@ -5,8 +5,6 @@ FROM $BASE_IMAGE as base SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG ROS_DISTRO -RUN echo "DO NOT MERGE" - # Install apt packages and add GitHub to known hosts for private repositories RUN rm -f /etc/apt/apt.conf.d/docker-clean \ && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache From 9d9054eae3615c803709174355a1496fdea37842 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Wed, 29 May 2024 15:05:14 +0900 Subject: [PATCH 09/10] remove upload artifact Signed-off-by: Yutaka Kondo --- .../actions/docker-build-and-push/action.yaml | 62 ------------------- 1 file changed, 62 deletions(-) diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index 4b33ffda7d2..d15de190e5d 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -130,65 +130,3 @@ runs: prebuilt.output=type=docker,dest=/tmp/prebuilt.tar devel.output=type=docker,dest=/tmp/devel.tar runtime.output=type=docker,dest=/tmp/runtime.tar - - - name: Upload Artifact - prebuilt - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} - id: artifact-upload-step-prebuilt - uses: actions/upload-artifact@v4 - with: - name: prebuilt-image${{ inputs.tag-suffix }} - path: /tmp/prebuilt.tar - retention-days: 7 - compression-level: 6 - overwrite: true - if-no-files-found: error - - - name: Remove tar file - prebuilt - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} - run: | - rm /tmp/prebuilt.tar - shell: bash - - - name: Upload Artifact - devel - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} - id: artifact-upload-step-devel - uses: actions/upload-artifact@v4 - with: - name: devel-image${{ inputs.tag-suffix }} - path: /tmp/devel.tar - retention-days: 7 - compression-level: 6 - overwrite: true - if-no-files-found: error - - - name: Remove tar file - devel - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} - run: | - rm /tmp/devel.tar - shell: bash - - - name: Upload Artifact - runtime - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} - id: artifact-upload-step-runtime - uses: actions/upload-artifact@v4 - with: - name: runtime-image${{ inputs.tag-suffix }} - path: /tmp/runtime.tar - retention-days: 7 - compression-level: 6 - overwrite: true - if-no-files-found: error - - - name: Remove tar file - runtime - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} - run: | - rm /tmp/runtime.tar - shell: bash - - - name: Output artifact URLs - id: output-artifact-urls - run: | - echo 'prebuilt URL ${{ steps.artifact-upload-step-prebuilt.outputs.artifact-url }}' - echo 'devel URL ${{ steps.artifact-upload-step-devel.outputs.artifact-url }}' - echo 'runtime URL ${{ steps.artifact-upload-step-runtime.outputs.artifact-url }}' - shell: bash From 9f3d4f515dd7dd760beac9ec175ecc1de30d31db Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Wed, 29 May 2024 15:10:00 +0900 Subject: [PATCH 10/10] remove build and push Signed-off-by: Yutaka Kondo --- .../actions/docker-build-and-push/action.yaml | 27 +++---------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index d15de190e5d..a0be389d9c0 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -85,8 +85,8 @@ runs: username: ${{ github.actor }} password: ${{ github.token }} - - name: Build and Push - prebuilt and devel - if: ${{ (github.event_name == 'push' && github.ref_type == 'branch') || github.event_name == 'schedule' }} + - name: Build and Push to GitHub Container Registry + if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || ( github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'registry') }} uses: docker/bake-action@v3 with: push: ${{ inputs.allow-push == 'true' }} @@ -94,39 +94,20 @@ runs: docker/docker-bake.hcl ${{ steps.meta-prebuilt.outputs.bake-file }} ${{ steps.meta-devel.outputs.bake-file }} - targets: | - prebuilt - devel - provenance: false - set: | - ${{ inputs.build-args }} - - - name: Build and Publish to GitHub Container Registry - if: ${{ ( github.event_name == 'push' && github.ref_type == 'tag' ) || ( github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'registry') }} - uses: docker/bake-action@v3 - with: - push: true - files: | - docker/docker-bake.hcl - ${{ steps.meta-devel.outputs.bake-file }} - ${{ steps.meta-prebuilt.outputs.bake-file }} ${{ steps.meta-runtime.outputs.bake-file }} provenance: false set: | ${{ inputs.build-args }} - - name: Build and Save Artifacts + - name: Build only uses: docker/bake-action@v3 with: push: false files: | docker/docker-bake.hcl - ${{ steps.meta-devel.outputs.bake-file }} ${{ steps.meta-prebuilt.outputs.bake-file }} + ${{ steps.meta-devel.outputs.bake-file }} ${{ steps.meta-runtime.outputs.bake-file }} provenance: false set: | ${{ inputs.build-args }} - prebuilt.output=type=docker,dest=/tmp/prebuilt.tar - devel.output=type=docker,dest=/tmp/devel.tar - runtime.output=type=docker,dest=/tmp/runtime.tar