diff --git a/.github/workflows/buildah-build-builder.yml b/.github/workflows/buildah-build-builder.yml index 7a7edb3..ff3abba 100644 --- a/.github/workflows/buildah-build-builder.yml +++ b/.github/workflows/buildah-build-builder.yml @@ -2,10 +2,11 @@ name: buildah-build-builder on: workflow_dispatch: schedule: - - cron: '30 12 * * 0' # 12:30 UTC every Sunday + - cron: "30 12 * * 0" # 12:30 UTC every Sunday push: paths: - - .github/workflows/buildah-build-builder.yml # Self-trigger + - containers/autoware-builder/** + - .github/workflows/buildah-build-builder.yml # Self-trigger env: REGISTRY: ghcr.io/bounverif @@ -30,11 +31,11 @@ jobs: uses: easimon/maximize-build-space@v10 with: root-reserve-mb: 2048 # Reserve disk space for repository - remove-dotnet: 'true' - remove-android: 'true' - remove-haskell: 'true' - remove-codeql: 'true' - remove-docker-images: 'true' + remove-dotnet: "true" + remove-android: "true" + remove-haskell: "true" + remove-codeql: "true" + remove-docker-images: "true" build-mount-path: ${{ env.CONTAINERS_ROOT }} # The remaining space only for container build - run: mkdir -p $TMPDIR @@ -63,8 +64,7 @@ jobs: oci: true build-args: | AUTOWARE_VERSION=${{ env.AUTOWARE_VERSION }} - extra-args: - --target autoware-builder + extra-args: --target autoware-builder --cache-to=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/cache containerfiles: | containers/autoware-builder/Dockerfile @@ -80,13 +80,13 @@ jobs: oci: true build-args: | AUTOWARE_VERSION=${{ env.AUTOWARE_VERSION }} - extra-args: - --target autoware-builder-with-cache + extra-args: --target autoware-builder-with-cache --cache-from=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/cache containerfiles: | containers/autoware-builder/Dockerfile - name: Push to GitHub Container Repository + if: github.ref == 'refs/heads/main' id: push-builder-ghcr uses: redhat-actions/push-to-registry@v2 with: @@ -95,6 +95,7 @@ jobs: tags: ${{ steps.build-builder.outputs.tags }} - name: Push to GitHub Container Repository + if: github.ref == 'refs/heads/main' id: push-builder-with-cache-ghcr uses: redhat-actions/push-to-registry@v2 with: diff --git a/.github/workflows/buildah-build-devel.yml b/.github/workflows/buildah-build-devel.yml index 0f83deb..625847b 100644 --- a/.github/workflows/buildah-build-devel.yml +++ b/.github/workflows/buildah-build-devel.yml @@ -9,7 +9,7 @@ on: - completed push: paths: - - .github/workflows/buildah-build-devel.yml # Self-trigger + - .github/workflows/buildah-build-devel.yml # Self-trigger env: REGISTRY: ghcr.io/bounverif @@ -29,16 +29,17 @@ permissions: jobs: autoware-devel-build: runs-on: ubuntu-24.04 + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Maximize build space uses: easimon/maximize-build-space@v10 with: root-reserve-mb: 2048 # Reserve disk space for repository - remove-dotnet: 'true' - remove-android: 'true' - remove-haskell: 'true' - remove-codeql: 'true' - remove-docker-images: 'true' + remove-dotnet: "true" + remove-android: "true" + remove-haskell: "true" + remove-codeql: "true" + remove-docker-images: "true" build-mount-path: ${{ env.CONTAINERS_ROOT }} # The remaining space only for container build - run: mkdir -p $TMPDIR @@ -62,12 +63,12 @@ jobs: tags: latest-devel layers: true oci: true - extra-args: - --target autoware-devel + extra-args: --target autoware-devel containerfiles: | containers/autoware-devel/Dockerfile - name: Push to GitHub Container Repository + if: github.ref == 'refs/heads/main' id: push-devel-ghcr uses: redhat-actions/push-to-registry@v2 with: diff --git a/containers/autoware-builder/Dockerfile b/containers/autoware-builder/Dockerfile index 818e2eb..c9e1bb9 100644 --- a/containers/autoware-builder/Dockerfile +++ b/containers/autoware-builder/Dockerfile @@ -18,8 +18,9 @@ LABEL org.opencontainers.image.title="Autoware" # Autoware variables ARG AUTOWARE_VERSION=latest ENV AUTOWARE_VERSION=${AUTOWARE_VERSION} -ENV AUTOWARE_SOURCE_DIR=/usr/local/src/autoware -ENV AUTOWARE_BUILD_DIR=/tmp/build/autoware +ENV AUTOWARE_ROOT=/root/autoware +ENV AUTOWARE_SOURCE_DIR=${AUTOWARE_ROOT}/src +ENV AUTOWARE_BUILD_DIR=${AUTOWARE_ROOT}/build ENV AUTOWARE_INSTALL_DIR=/opt/autoware/humble # Debian containers save no deb archives by default. @@ -103,7 +104,7 @@ ENV CMAKE_GENERATOR=Ninja ENV CMAKE_C_COMPILER_LAUNCHER=ccache ENV CMAKE_CXX_COMPILER_LAUNCHER=ccache ENV CMAKE_CUDA_COMPILER_LAUNCHER=ccache -ENV CCACHE_BASEDIR=${AUTOWARE_SOURCE_DIR} +ENV CCACHE_BASEDIR=${AUTOWARE_ROOT} ENV CCACHE_DIR=/var/cache/ccache # Set environment variables for all users @@ -150,7 +151,7 @@ RUN --mount=type=bind,from=autoware-source,source=${AUTOWARE_SOURCE_DIR},target= . /opt/ros/humble/setup.sh && \ colcon --log-base /dev/null build \ --base-paths ${AUTOWARE_SOURCE_DIR} \ - --build-base /tmp/build \ + --build-base ${AUTOWARE_BUILD_DIR} \ --install-base /tmp/install \ --packages-up-to autoware_launch \ --event-handlers \ @@ -166,6 +167,8 @@ RUN --mount=type=bind,from=autoware-source,source=${AUTOWARE_SOURCE_DIR},target= -DCMAKE_BUILD_TYPE=Release \ " -Wno-dev" \ " --no-warn-unused-cli" \ - && rm -rf /tmp/build \ + && rm -rf ${AUTOWARE_SOURCE_DIR} \ + && rm -rf ${AUTOWARE_BUILD_DIR} \ + && rm -rf ${AUTOWARE_ROOT} \ && rm -rf /tmp/install \ && du -h --max-depth=0 ${CCACHE_DIR}