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 23, 2023
1 parent f732be8 commit a7fa377
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
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 a7fa377

Please sign in to comment.