From c56454edc12aa8b15a38725418748262badffd2b Mon Sep 17 00:00:00 2001 From: KevFan Date: Mon, 23 Oct 2023 10:45:32 +0100 Subject: [PATCH] fix: explicitly set targetplatform --- .github/workflows/build-image.yaml | 19 ++++++++++--------- Dockerfile | 2 +- Dockerfile.aarch64 | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index b9898d8a..c609becd 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -20,9 +20,9 @@ jobs: fail-fast: false matrix: include: - - dockerfile: ./Dockerfile + - dockerfile: Dockerfile platform: linux/amd64 - - dockerfile: ./Dockerfile.aarch64 + - dockerfile: Dockerfile.aarch64 platform: linux/arm64 steps: - name: Check out code @@ -47,17 +47,15 @@ jobs: with: context: . labels: ${{ steps.meta.outputs.labels }} -# build-args: | -# GITHUB_SHA=${{ github.sha }} + build-args: | + GITHUB_SHA=${{ github.sha }} cache-from: type=gha,scope=${{ matrix.platform == 'linux/amd64' && 'build-amd' || 'build-arm'}} cache-to: type=gha,mode=max,scope=${{ matrix.platform == 'linux/amd64' && 'build-amd' || 'build-arm'}} outputs: type=image,name=${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador,push-by-digest=true,name-canonical=true,push=true file: ${{ matrix.dockerfile }} platforms: | ${{ matrix.platform }} -# - name: Smoke Test -# run: | -# docker run --rm -t ${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ github.sha }} limitador-server --help + provenance: false - name: Export digest run: | mkdir -p /tmp/digests @@ -104,7 +102,7 @@ jobs: tags: | # type=raw,value=${{ github.sha }} # set latest tag for main branch - # type=raw,value=latest,enable=${{ github.ref_name == env.MAIN_BRANCH_NAME }} + type=raw,value=latest,enable=${{ github.ref_name == env.MAIN_BRANCH_NAME }} # set branch name tag for non-main branches type=raw,value=${{ github.ref_name }},enable=${{ github.ref_name != env.MAIN_BRANCH_NAME }} - name: Login to container registry @@ -120,4 +118,7 @@ jobs: $(printf '${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador@sha256:%s ' *) - name: Inspect image run: | - docker buildx imagetools inspect ${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ steps.meta.outputs.version }} \ No newline at end of file + docker buildx imagetools inspect ${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ steps.meta.outputs.version }} + - name: Smoke Test + run: | + docker run --rm -t ${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ steps.meta.outputs.version }} limitador-server --help \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 853a113a..2fa9ddbd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ RUN source $HOME/.cargo/env \ # Run Stage # ------------------------------------------------------------------------------ -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7 +FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi8/ubi-minimal:8.7 # shadow-utils is required for `useradd` RUN PKGS="libgcc libstdc++ shadow-utils" \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 3a6d9f94..b03e8ebc 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -29,7 +29,7 @@ RUN cargo build --release --target aarch64-unknown-linux-gnu # Run Stage # ------------------------------------------------------------------------------ -FROM gcr.io/distroless/cc-debian12 +FROM --platform=$TARGETPLATFORM gcr.io/distroless/cc-debian12 WORKDIR /home/limitador/bin/ ENV PATH="/home/limitador/bin:${PATH}"