From 41c495ca5a9459004f9b02122517e4af1315ace8 Mon Sep 17 00:00:00 2001 From: Eric Deandrea Date: Mon, 17 Oct 2022 14:56:30 -0400 Subject: [PATCH] Build multi-arch native images Fixes #80 --- .../workflows/build-push-container-images.yml | 40 ++++--------------- .../src/main/docker/Dockerfile.native | 2 +- .../main/docker/Dockerfile.native-distroless | 2 +- rest-fights/src/main/docker/Dockerfile.native | 2 +- .../main/docker/Dockerfile.native-distroless | 2 +- rest-heroes/src/main/docker/Dockerfile.native | 2 +- .../main/docker/Dockerfile.native-distroless | 2 +- .../src/main/docker/Dockerfile.native | 2 +- .../main/docker/Dockerfile.native-distroless | 2 +- 9 files changed, 16 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build-push-container-images.yml b/.github/workflows/build-push-container-images.yml index 36c6bc3aa..a92dc3c50 100644 --- a/.github/workflows/build-push-container-images.yml +++ b/.github/workflows/build-push-container-images.yml @@ -122,8 +122,8 @@ jobs: - rest-villains arch: - amd64 - # - arm64 - name: "Build Native images (${{ matrix.arch}}-${{ matrix.project }}-java${{ matrix.java }})" + - arm64 + name: "Build Native images (${{ matrix.arch }}-${{ matrix.project }}-java${{ matrix.java }})" steps: - name: Calculate Branch (workflow_run event) if: github.event_name == 'workflow_run' @@ -178,6 +178,7 @@ jobs: -Dquarkus.http.host=0.0.0.0 \ -Dquarkus.native.container-build=true \ -Dquarkus.native.builder-image=${{ env.MANDREL_IMAGE }}:${{ env.MANDREL_VERSION }}-java${{ matrix.java }} \ + -Dquarkus.native.container-runtime-options=--platform=linux/${{ matrix.arch }} \ -Dquarkus.container-image.build=true \ -Dquarkus.container-image.push=false \ -Dquarkus.container-image.tag=${{ env.CONTAINER_TAG }}-${{ matrix.arch }} \ @@ -273,25 +274,23 @@ jobs: name: "Push app images (${{ matrix.arch}}-${{ matrix.project }}-${{ matrix.kind }}java${{ matrix.java }})" steps: - name: Calculate Branch (workflow_run event) - if: ((matrix.arch == 'amd64') || (matrix.kind != 'native-')) && (github.event_name == 'workflow_run') + if: github.event_name == 'workflow_run' run: | echo "REF=${{ github.event.workflow_run.head_commit.id }}" >> $GITHUB_ENV echo "BRANCH=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_ENV - name: Calculate Branch (workflow_dispatch event) - if: ((matrix.arch == 'amd64') || (matrix.kind != 'native-')) && (github.event_name == 'workflow_dispatch') + if: github.event_name == 'workflow_dispatch' run: | echo "REF=${{ github.sha }}" >> $GITHUB_ENV echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV - name: Checkout from ${{ env.REF }} - if: (matrix.arch == 'amd64') || (matrix.kind != 'native-') uses: actions/checkout@v3 with: ref: ${{ env.REF }} - name: Setup Java - if: (matrix.arch == 'amd64') || (matrix.kind != 'native-') uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} @@ -299,34 +298,31 @@ jobs: cache: maven - name: Create env vars - if: (matrix.arch == 'amd64') || (matrix.kind != 'native-') working-directory: ${{ matrix.project }} run: | echo "QUARKUS_VERSION=$(./mvnw help:evaluate -Dexpression=quarkus.platform.version -q -DforceStdout)" >> $GITHUB_ENV && echo "APP_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV - name: Create container tags (main branch) - if: (env.BRANCH == 'main') && ((matrix.arch == 'amd64') || (matrix.kind != 'native-')) + if: env.BRANCH == 'main' working-directory: ${{ matrix.project }} run: | echo "CONTAINER_TAG=${{ env.APP_VERSION }}-quarkus-${{ env.QUARKUS_VERSION }}-${{ matrix.kind }}java${{ matrix.java }}" >> $GITHUB_ENV && echo "ADDITIONAL_TAG=${{ matrix.kind }}java${{ matrix.java }}-${{ env.LATEST_IMAGE_TAG }}" >> $GITHUB_ENV - name: Create container tags (other branch) - if: (env.BRANCH != 'main') && ((matrix.arch == 'amd64') || (matrix.kind != 'native-')) + if: env.BRANCH != 'main' working-directory: ${{ matrix.project }} run: | echo "CONTAINER_TAG=${{ env.APP_VERSION }}-quarkus-${{ env.QUARKUS_VERSION }}-${{ matrix.kind }}java${{ matrix.java }}" >> $GITHUB_ENV && echo "ADDITIONAL_TAG=${{ matrix.kind }}java${{ matrix.java }}-${{ env.LATEST_IMAGE_TAG }}-${{ env.BRANCH }}" >> $GITHUB_ENV - name: Get saved images (${{ matrix.project }}-${{ matrix.kind }}java${{ matrix.java }}-${{ matrix.arch }}) - if: (matrix.arch == 'amd64') || (matrix.kind != 'native-') uses: ishworkh/docker-image-artifact-download@v1 with: image: "${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-${{ matrix.arch }}" - name: Login to quay - if: (matrix.arch == 'amd64') || (matrix.kind != 'native-') uses: docker/login-action@v2 with: registry: quay.io @@ -334,19 +330,10 @@ jobs: password: ${{ secrets.QUAY_REPO_TOKEN }} - name: Tag image - if: (matrix.arch == 'amd64') || (matrix.kind != 'native-') working-directory: ${{ matrix.project }} run: "docker tag ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-${{ matrix.arch }} ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }}-${{ matrix.arch }}" - - name: Tag native image (amd64) - if: (matrix.arch == 'amd64') && (matrix.kind == 'native-') - working-directory: ${{ matrix.project }} - run: | - docker tag ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-${{ matrix.arch }} ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }} - docker tag ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-${{ matrix.arch }} ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }} - - name: Push images - if: (matrix.arch == 'amd64') || (matrix.kind != 'native-') working-directory: ${{ matrix.project }} run: "docker push -a ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}" @@ -432,7 +419,7 @@ jobs: - '17' kind: - "" -# - "native-" + - "native-" project: - event-statistics - rest-fights @@ -503,17 +490,6 @@ jobs: -a ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }}-arm64 docker manifest push ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }} -# - name: Create and push single-arch native manifests -# if: matrix.kind == 'native-' -# shell: bash -# run: | -# docker manifest create ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }} \ -# -a ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-amd64 -# docker manifest push ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }} -# docker manifest create ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }} \ -# -a ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }}-amd64 -# docker manifest push ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }} - create-ui-multiarch-manifests: if: ((github.event_name == 'workflow_dispatch') || ((github.event_name == 'workflow_run') && ((github.event.workflow_run.event == 'push') || (github.event.workflow_run.event == 'workflow_dispatch')) && (github.event.workflow_run.conclusion == 'success'))) && ((github.repository == 'quarkusio/quarkus-super-heroes') && ((github.event.workflow_run.head_branch == 'main') || (github.event.workflow_run.head_branch == 'rhbq-2.7'))) needs: push-ui-images diff --git a/event-statistics/src/main/docker/Dockerfile.native b/event-statistics/src/main/docker/Dockerfile.native index 9138e8cfa..2e223e6a9 100644 --- a/event-statistics/src/main/docker/Dockerfile.native +++ b/event-statistics/src/main/docker/Dockerfile.native @@ -17,7 +17,7 @@ # docker run -i --rm -p 8085:8085 quarkus/event-statistics # ### -FROM quay.io/quarkus/quarkus-micro-image:1.0 +FROM quay.io/quarkus/quarkus-micro-image:2.0 WORKDIR /work/ RUN chown 1001 /work \ && chmod "g+rwX" /work \ diff --git a/event-statistics/src/main/docker/Dockerfile.native-distroless b/event-statistics/src/main/docker/Dockerfile.native-distroless index c4d1f000c..91f73e640 100644 --- a/event-statistics/src/main/docker/Dockerfile.native-distroless +++ b/event-statistics/src/main/docker/Dockerfile.native-distroless @@ -14,7 +14,7 @@ # docker run -i --rm -p 8085:8085 quarkus/event-statistics # ### -FROM quay.io/quarkus/quarkus-distroless-image:1.0 +FROM quay.io/quarkus/quarkus-distroless-image:2.0 COPY target/*-runner /application EXPOSE 8085 diff --git a/rest-fights/src/main/docker/Dockerfile.native b/rest-fights/src/main/docker/Dockerfile.native index 189614a95..4136e00bd 100644 --- a/rest-fights/src/main/docker/Dockerfile.native +++ b/rest-fights/src/main/docker/Dockerfile.native @@ -17,7 +17,7 @@ # docker run -i --rm -p 8082:8082 quarkus/rest-fights # ### -FROM quay.io/quarkus/quarkus-micro-image:1.0 +FROM quay.io/quarkus/quarkus-micro-image:2.0 WORKDIR /work/ RUN chown 1001 /work \ && chmod "g+rwX" /work \ diff --git a/rest-fights/src/main/docker/Dockerfile.native-distroless b/rest-fights/src/main/docker/Dockerfile.native-distroless index b4a7b02a1..2cf753181 100644 --- a/rest-fights/src/main/docker/Dockerfile.native-distroless +++ b/rest-fights/src/main/docker/Dockerfile.native-distroless @@ -14,7 +14,7 @@ # docker run -i --rm -p 8082:8082 quarkus/rest-fights # ### -FROM quay.io/quarkus/quarkus-distroless-image:1.0 +FROM quay.io/quarkus/quarkus-distroless-image:2.0 COPY target/*-runner /application EXPOSE 8082 diff --git a/rest-heroes/src/main/docker/Dockerfile.native b/rest-heroes/src/main/docker/Dockerfile.native index d523603c6..e75fc71b7 100644 --- a/rest-heroes/src/main/docker/Dockerfile.native +++ b/rest-heroes/src/main/docker/Dockerfile.native @@ -17,7 +17,7 @@ # docker run -i --rm -p 8083:8083 quarkus/rest-heroes # ### -FROM quay.io/quarkus/quarkus-micro-image:1.0 +FROM quay.io/quarkus/quarkus-micro-image:2.0 WORKDIR /work/ RUN chown 1001 /work \ && chmod "g+rwX" /work \ diff --git a/rest-heroes/src/main/docker/Dockerfile.native-distroless b/rest-heroes/src/main/docker/Dockerfile.native-distroless index 3f25bca32..926227bb3 100644 --- a/rest-heroes/src/main/docker/Dockerfile.native-distroless +++ b/rest-heroes/src/main/docker/Dockerfile.native-distroless @@ -14,7 +14,7 @@ # docker run -i --rm -p 8083:8083 quarkus/rest-heroes # ### -FROM quay.io/quarkus/quarkus-distroless-image:1.0 +FROM quay.io/quarkus/quarkus-distroless-image:2.0 COPY target/*-runner /application EXPOSE 8083 diff --git a/rest-villains/src/main/docker/Dockerfile.native b/rest-villains/src/main/docker/Dockerfile.native index 24f8ea43d..a06b4efe1 100644 --- a/rest-villains/src/main/docker/Dockerfile.native +++ b/rest-villains/src/main/docker/Dockerfile.native @@ -17,7 +17,7 @@ # docker run -i --rm -p 8084:8084 quarkus/rest-villains # ### -FROM quay.io/quarkus/quarkus-micro-image:1.0 +FROM quay.io/quarkus/quarkus-micro-image:2.0 WORKDIR /work/ RUN chown 1001 /work \ && chmod "g+rwX" /work \ diff --git a/rest-villains/src/main/docker/Dockerfile.native-distroless b/rest-villains/src/main/docker/Dockerfile.native-distroless index 4a07c3b94..86ed6c9c3 100644 --- a/rest-villains/src/main/docker/Dockerfile.native-distroless +++ b/rest-villains/src/main/docker/Dockerfile.native-distroless @@ -14,7 +14,7 @@ # docker run -i --rm -p 8084:8084 quarkus/rest-villains # ### -FROM quay.io/quarkus/quarkus-distroless-image:1.0 +FROM quay.io/quarkus/quarkus-distroless-image:2.0 COPY target/*-runner /application EXPOSE 8084