diff --git a/.github/actions/docker-build-and-push/action.yaml b/.github/actions/docker-build-and-push/action.yaml index e2fb347e5c5..7804e9e1ccf 100644 --- a/.github/actions/docker-build-and-push/action.yaml +++ b/.github/actions/docker-build-and-push/action.yaml @@ -1,199 +1,201 @@ -name: docker-build-and-push -description: "" - -inputs: - bake-target: - description: "" - required: true - build-args: - description: "" - required: false - tag-prefix: - description: "" - required: false - tag-suffix: - description: "" - required: false - allow-push: - description: "" - default: "true" - required: false - -runs: - using: composite - steps: - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Install jq - run: | - sudo apt-get -y update - sudo apt-get -y install jq - shell: bash - - - name: Set Docker tags - id: set-docker-tags - run: | - tags=() - if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref_type }}" == "tag" ]; then - tags+=("$(echo "${{ github.ref }}" | sed -E 's/.*([vV][0-9]+\.[0-9]+\.[0-9]+).*/\1/')") - fi - - tags+=("{{date 'YYYYMMDD'}}") - tags+=("latest") - tags+=("latest-${{ inputs.tag-prefix }}") - - # Output multiline strings: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings - EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) - echo "tags<<$EOF" >> $GITHUB_OUTPUT - echo "$(printf "%s\n" "${tags[@]}")" >> $GITHUB_OUTPUT - echo "$EOF" >> $GITHUB_OUTPUT - shell: bash - - - name: Docker meta for base - id: meta-base - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} - tags: ${{ steps.set-docker-tags.outputs.tags }} - bake-target: docker-metadata-action-base - flavor: | - latest=false - suffix=-base${{ inputs.tag-suffix }} - - - name: Docker meta for prebuilt - id: meta-prebuilt - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} - tags: ${{ steps.set-docker-tags.outputs.tags }} - bake-target: docker-metadata-action-prebuilt - flavor: | - latest=false - suffix=-prebuilt${{ inputs.tag-suffix }} - - - name: Docker meta for devel - id: meta-devel - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} - tags: ${{ steps.set-docker-tags.outputs.tags }} - bake-target: docker-metadata-action-devel - flavor: | - latest=false - suffix=-devel${{ inputs.tag-suffix }} - - - name: Docker meta for runtime - if: ${{ github.event_name == 'workflow_dispatch' }} || ${{ (github.event_name == 'push' && github.ref_type == 'tag') }} - id: meta-runtime - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} - tags: ${{ steps.set-docker-tags.outputs.tags }} - bake-target: docker-metadata-action-runtime - flavor: | - latest=${{ github.event_name == 'push' && github.ref_type == 'tag' }} - suffix=-runtime${{ inputs.tag-suffix }} - - - name: Login to GitHub Container Registry - if: ${{ github.event_name != 'pull_request' }} - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ github.token }} - - - name: Build and Push - prebuilt and devel - if: ${{ (github.event_name == 'push' && github.ref_type == 'branch') || github.event_name == 'schedule' }} - uses: docker/bake-action@v3 - with: - push: ${{ inputs.allow-push == 'true' }} - files: | - docker/${{ inputs.bake-target }}/docker-bake.hcl - ${{ steps.meta-base.outputs.bake-file }} - ${{ steps.meta-prebuilt.outputs.bake-file }} - ${{ steps.meta-devel.outputs.bake-file }} - targets: | - base - 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/${{ inputs.bake-target }}/docker-bake.hcl - ${{ steps.meta-base.outputs.bake-file }} - ${{ 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 - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} - uses: docker/bake-action@v3 - with: - push: false - files: | - docker/${{ inputs.bake-target }}/docker-bake.hcl - ${{ steps.meta-base.outputs.bake-file }} - ${{ steps.meta-devel.outputs.bake-file }} - ${{ steps.meta-prebuilt.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 - - - 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: 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: 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: 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 +name: docker-build-and-push +description: "" + +inputs: + bake-target: + description: "" + required: true + bake-target-modular: + description: "" + required: true + build-args: + description: "" + required: false + tag-prefix: + description: "" + required: false + tag-suffix: + description: "" + required: false + allow-push: + description: "" + default: "true" + required: false + +runs: + using: composite + steps: + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Install jq + run: | + sudo apt-get -y update + sudo apt-get -y install jq + shell: bash + + - name: Set Docker tags + id: set-docker-tags + run: | + tags=() + if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref_type }}" == "tag" ]; then + tags+=("$(echo "${{ github.ref }}" | sed -E 's/.*([vV][0-9]+\.[0-9]+\.[0-9]+).*/\1/')") + fi + + tags+=("{{date 'YYYYMMDD'}}") + tags+=("latest") + tags+=("latest-${{ inputs.tag-prefix }}") + + # Output multiline strings: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + echo "tags<<$EOF" >> $GITHUB_OUTPUT + echo "$(printf "%s\n" "${tags[@]}")" >> $GITHUB_OUTPUT + echo "$EOF" >> $GITHUB_OUTPUT + shell: bash + + - name: Docker meta for base + id: meta-base + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target-modular }} + tags: ${{ steps.set-docker-tags.outputs.tags }} + bake-target: docker-metadata-action-base + flavor: | + latest=false + suffix=-base${{ inputs.tag-suffix }} + + - name: Docker meta for prebuilt + id: meta-prebuilt + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} + tags: ${{ steps.set-docker-tags.outputs.tags }} + bake-target: docker-metadata-action-prebuilt + flavor: | + latest=false + suffix=-prebuilt${{ inputs.tag-suffix }} + + - name: Docker meta for devel + id: meta-devel + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} + tags: ${{ steps.set-docker-tags.outputs.tags }} + bake-target: docker-metadata-action-devel + flavor: | + latest=false + suffix=-devel${{ inputs.tag-suffix }} + + - name: Docker meta for runtime + if: ${{ github.event_name == 'workflow_dispatch' }} || ${{ (github.event_name == 'push' && github.ref_type == 'tag') }} + id: meta-runtime + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }} + tags: ${{ steps.set-docker-tags.outputs.tags }} + bake-target: docker-metadata-action-runtime + flavor: | + latest=${{ github.event_name == 'push' && github.ref_type == 'tag' }} + suffix=-runtime${{ inputs.tag-suffix }} + + - name: Login to GitHub Container Registry + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ github.token }} + + - name: Build and Push - prebuilt and devel + if: ${{ (github.event_name == 'push' && github.ref_type == 'branch') || github.event_name == 'schedule' }} + uses: docker/bake-action@v3 + with: + push: ${{ inputs.allow-push == 'true' }} + files: | + docker/${{ inputs.bake-target }}/docker-bake.hcl + ${{ steps.meta-base.outputs.bake-file }} + ${{ steps.meta-prebuilt.outputs.bake-file }} + ${{ steps.meta-devel.outputs.bake-file }} + targets: | + base + 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/${{ inputs.bake-target }}/docker-bake.hcl + ${{ steps.meta-base.outputs.bake-file }} + targets: | + base + provenance: false + set: | + ${{ inputs.build-args }} + + - name: Build and Save Artifacts + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }} + uses: docker/bake-action@v3 + with: + push: false + files: | + docker/${{ inputs.bake-target }}/docker-bake.hcl + ${{ steps.meta-base.outputs.bake-file }} + ${{ steps.meta-devel.outputs.bake-file }} + ${{ steps.meta-prebuilt.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 + + - 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: 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: 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: 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 diff --git a/.github/workflows/docker-build-and-push-main-self-hosted.yaml b/.github/workflows/docker-build-and-push-main-self-hosted.yaml index 315e5b1ed07..9382f8353a7 100644 --- a/.github/workflows/docker-build-and-push-main-self-hosted.yaml +++ b/.github/workflows/docker-build-and-push-main-self-hosted.yaml @@ -66,6 +66,7 @@ jobs: uses: ./.github/actions/docker-build-and-push with: bake-target: autoware-openadk + bake-target-modular: autoware-openadk-modular build-args: | *.platform=linux/arm64 *.args.ROS_DISTRO=${{ env.rosdistro }} diff --git a/docker/autoware-openadk/docker-bake.hcl b/docker/autoware-openadk/docker-bake.hcl index c1b40c68abf..59c5903f0fa 100644 --- a/docker/autoware-openadk/docker-bake.hcl +++ b/docker/autoware-openadk/docker-bake.hcl @@ -7,6 +7,10 @@ target "docker-metadata-action-base" {} target "docker-metadata-action-prebuilt" {} target "docker-metadata-action-devel" {} target "docker-metadata-action-runtime" {} +target "docker-metadata-action-perception-localization" {} +target "docker-metadata-action-planning-control" {} +target "docker-metadata-action-visualizer" {} +target "docker-metadata-action-simulator" {} target "base" { inherits = ["docker-metadata-action-prebuilt"] @@ -31,3 +35,27 @@ target "runtime" { dockerfile = "docker/autoware-openadk/Dockerfile" target = "runtime" } + +target "perception-localization" { + inherits = ["docker-metadata-action-runtime"] + dockerfile = "docker/autoware-openadk/services/perception-localization/Dockerfile" + target = "perception-localization" +} + +target "planning-control" { + inherits = ["docker-metadata-action-runtime"] + dockerfile = "docker/autoware-openadk/services/planning-control/Dockerfile" + target = "planning-control" +} + +target "visualizer" { + inherits = ["docker-metadata-action-runtime"] + dockerfile = "docker/autoware-openadk/services/visualizer/Dockerfile" + target = "visualizer" +} + +target "simulator" { + inherits = ["docker-metadata-action-runtime"] + dockerfile = "docker/autoware-openadk/services/simulator/Dockerfile" + target = "simulator" +} diff --git a/docker/autoware-openadk/services/perception-localization/Dockerfile b/docker/autoware-openadk/services/perception-localization/Dockerfile index 2d213b306bb..57dcd113839 100644 --- a/docker/autoware-openadk/services/perception-localization/Dockerfile +++ b/docker/autoware-openadk/services/perception-localization/Dockerfile @@ -1,5 +1,5 @@ ARG PLATFORM -FROM ghcr.io/autowarefoundation/autoware-openadk:latest-base-${PLATFORM} as base +FROM ghcr.io/autowarefoundation/autoware-openadk-modular:latest-base-${PLATFORM} as perception-localization SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG PLATFORM ARG ROS_DISTRO diff --git a/docker/autoware-openadk/services/planning-control/Dockerfile b/docker/autoware-openadk/services/planning-control/Dockerfile index a8f90d21407..192725412f2 100644 --- a/docker/autoware-openadk/services/planning-control/Dockerfile +++ b/docker/autoware-openadk/services/planning-control/Dockerfile @@ -1,5 +1,5 @@ ARG PLATFORM -FROM ghcr.io/autowarefoundation/autoware-openadk:latest-base-${PLATFORM} as base +FROM ghcr.io/autowarefoundation/autoware-openadk-modular:latest-base-${PLATFORM} as planning-control SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG PLATFORM ARG ROS_DISTRO diff --git a/docker/autoware-openadk/services/simulator/Dockerfile b/docker/autoware-openadk/services/simulator/Dockerfile index 7cc15bff439..0cb7f6184cf 100644 --- a/docker/autoware-openadk/services/simulator/Dockerfile +++ b/docker/autoware-openadk/services/simulator/Dockerfile @@ -1,5 +1,5 @@ ARG PLATFORM -FROM ghcr.io/autowarefoundation/autoware-openadk:latest-base-${PLATFORM} as base +FROM ghcr.io/autowarefoundation/autoware-openadk-modular:latest-base-${PLATFORM} as simulator-base SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG PLATFORM ARG ROS_DISTRO diff --git a/docker/autoware-openadk/services/visualizer/Dockerfile b/docker/autoware-openadk/services/visualizer/Dockerfile index 377266fada6..b1e972b5854 100644 --- a/docker/autoware-openadk/services/visualizer/Dockerfile +++ b/docker/autoware-openadk/services/visualizer/Dockerfile @@ -1,5 +1,5 @@ ARG PLATFORM -FROM ghcr.io/autowarefoundation/autoware-openadk:latest-base-${PLATFORM} as base +FROM ghcr.io/autowarefoundation/autoware-openadk-modular:latest-base-${PLATFORM} as visualizer SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG PLATFORM ARG ROS_DISTRO