Skip to content

Commit

Permalink
fix: explicitly set targetplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
KevFan committed Oct 24, 2023
1 parent f732be8 commit 3a04a98
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ jobs:
fail-fast: false
matrix:
include:
- dockerfile: ./Dockerfile
- dockerfile: Dockerfile
platform: linux/amd64
- dockerfile: ./Dockerfile.aarch64
- dockerfile: Dockerfile.aarch64
platform: linux/arm64
steps:
- name: Set image name
run: |
echo "IMG=${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador" >> "$GITHUB_ENV"
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
Expand All @@ -34,7 +37,7 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador
${{ env.IMG }}
- name: Login to container registry
uses: docker/login-action@v2
with:
Expand All @@ -47,17 +50,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
outputs: type=image,name=${{ env.IMG }},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
Expand Down Expand Up @@ -100,11 +101,11 @@ jobs:
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador
${{ env.IMG }}
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
Expand All @@ -117,7 +118,10 @@ jobs:
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador@sha256:%s ' *)
$(printf '${{ env.IMG }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.IMG_REGISTRY_HOST}}/${{ env.IMG_REGISTRY_ORG }}/limitador:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ env.IMG }}:${{ steps.meta.outputs.version }}
- name: Smoke Test
run: |
docker run --rm -t ${{ env.IMG }}:${{ steps.meta.outputs.version }} limitador-server --help
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Build Stage
# ------------------------------------------------------------------------------

FROM --platform=${BUILDPLATFORM} registry.access.redhat.com/ubi8/ubi:8.7 as limitador-build
FROM registry.access.redhat.com/ubi8/ubi:8.7 as limitador-build
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true

ARG RUSTC_VERSION=1.72.0
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 3a04a98

Please sign in to comment.