Skip to content

Commit a61701e

Browse files
authored
fix: Multi arch. docker images and binary mismatch (#382)
* fix: Multi arch. docker images and binary mismatch * fix: Increase timeout and adjust docker scan image * fix: Comment out arm64 image build * fix: Pin base images to latest sha256 digest
1 parent a6a06f6 commit a61701e

File tree

4 files changed

+62
-13
lines changed

4 files changed

+62
-13
lines changed

.github/workflows/ci.yaml

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ jobs:
230230
fail_ci_if_error: false
231231
docker-scan:
232232
runs-on: ubuntu-latest
233-
timeout-minutes: 20
233+
timeout-minutes: 45
234234
needs: [changed_files, ci]
235235
if: |
236236
${{ github.event.pull_request.draft == false && needs.changed_files.outputs.changed-docker-files == 'true' }}
@@ -242,23 +242,68 @@ jobs:
242242
egress-policy: audit
243243
- name: Checkout Code
244244
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
245+
- name: Setup QEMU
246+
uses: docker/setup-qemu-action@e77e8065d9f7ec6abdd9838668cd7b43924dd64d # main
247+
with:
248+
platforms: linux/amd64,linux/arm64
245249
- name: Prepare
246250
id: init
247251
uses: ./.github/actions/prepare
248252
- name: Set up Docker Buildx
249253
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
250-
- name: Build local container
254+
- name: Build x86 local container
251255
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
252256
with:
253-
tags: openzeppelin-monitor-dev:${{ github.sha }}
257+
tags: openzeppelin-monitor-dev:${{ github.sha }}-amd64
254258
push: false
255259
load: true
256260
file: Dockerfile.development
257261
platforms: linux/amd64
262+
# - name: Build arm64 local container
263+
# uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
264+
# with:
265+
# tags: openzeppelin-monitor-dev:${{ github.sha }}-arm64
266+
# push: false
267+
# load: true
268+
# file: Dockerfile.development
269+
# platforms: linux/arm64
270+
- name: Test image and binary architectures
271+
run: |
272+
set -euo pipefail
273+
# platforms=("amd64" "arm64")
274+
platforms=("amd64")
275+
for platform in "${platforms[@]}"; do
276+
image_tag="openzeppelin-monitor-dev:${{ github.sha }}-${platform}"
277+
echo ">>>>>>>>Inspecting $platform<<<<<<<<"
278+
image_arch=$(docker image inspect $image_tag --format '{{.Architecture}}')
279+
binary_info=$(docker run --rm --platform linux/$platform --entrypoint sh $image_tag -c \
280+
"apk add --no-cache file >/dev/null && file openzeppelin-monitor")
281+
echo ">>>>>>>>Binary info: $binary_info<<<<<<<<"
282+
283+
# Determine binary architecture
284+
case "$binary_info" in
285+
*"ARM aarch64"*)
286+
binary_arch="arm64"
287+
;;
288+
*"x86-64"*)
289+
binary_arch="amd64"
290+
;;
291+
*)
292+
echo "Unknown binary architecture: $binary_info........."
293+
exit 1
294+
;;
295+
esac
296+
echo ">>>>>>>>Image arch: $image_arch | Binary arch: $binary_arch<<<<<<<<"
297+
if [ "$image_arch" != "$binary_arch" ]; then
298+
echo ">>>>>>>Architecture mismatch: Image=$image_arch Binary=$binary_arch<<<<<<<"
299+
exit 1
300+
fi
301+
echo ">>>>>>>Architecture match for $platform<<<<<<<<"
302+
done
258303
- name: Scan image
259304
uses: anchore/scan-action@f6601287cdb1efc985d6b765bbf99cb4c0ac29d8 # v7.0.0
260305
with:
261-
image: openzeppelin-monitor-dev:${{ github.sha }}
306+
image: openzeppelin-monitor-dev:${{ github.sha }}-amd64
262307
fail-build: true
263308
severity-cutoff: high
264309
output-format: table

.github/workflows/release-docker.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ jobs:
6464
with:
6565
username: ${{ vars.DOCKERHUB_USERNAME }}
6666
password: ${{ secrets.DOCKERHUB_PAT }}
67+
- name: Setup QEMU
68+
uses: docker/setup-qemu-action@e77e8065d9f7ec6abdd9838668cd7b43924dd64d # main
69+
with:
70+
platforms: linux/amd64,linux/arm64
6771
- name: Set Up Docker Buildx
6872
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
6973
- name: Build Docker image

Dockerfile.development

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Base image
2-
FROM --platform=${BUILDPLATFORM} cgr.dev/chainguard/rust:latest-dev@sha256:faf49718aaa95c798ed1dfdf3e4edee2cdbc3790c8994705ca6ef35972128459 AS base
1+
# Base image with latest-dev tag digest
2+
FROM cgr.dev/chainguard/rust@sha256:74aa2608956c114e507dfde8fe31b1e4d42157dad67c29e06337680dedd940e9 AS base
33

44
WORKDIR /usr/app
55

@@ -13,8 +13,8 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
1313
--mount=type=cache,target=/app/target \
1414
RUST_BACKTRACE=1 cargo install --root /usr/app --path . --debug --locked
1515

16-
# Wolfi image
17-
FROM --platform=${BUILDPLATFORM} cgr.dev/chainguard/wolfi-base:latest
16+
# Wolfi image with latest tag digest
17+
FROM cgr.dev/chainguard/wolfi-base@sha256:9608820b6ea4da8bcf16989dac37a280f8f1fa0022efc45b5ed4b1ac1f634a79
1818

1919
ARG version=3.12
2020

Dockerfile.production

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Base image
2-
FROM --platform=${BUILDPLATFORM} cgr.dev/chainguard/rust:latest-dev@sha256:faf49718aaa95c798ed1dfdf3e4edee2cdbc3790c8994705ca6ef35972128459 AS base
1+
# Base image with latest-dev tag digest
2+
FROM cgr.dev/chainguard/rust@sha256:74aa2608956c114e507dfde8fe31b1e4d42157dad67c29e06337680dedd940e9 AS base
33

44
WORKDIR /usr/app
55

@@ -9,10 +9,10 @@ RUN apk update && apk add openssl-dev
99
COPY . .
1010
RUN --mount=type=cache,target=/usr/local/cargo/registry \
1111
--mount=type=cache,target=/app/target \
12-
cargo install --root /usr/app --path . --locked
12+
cargo install --root /usr/app --path . --profile release --locked
1313

14-
# Wolfi image
15-
FROM --platform=${BUILDPLATFORM} cgr.dev/chainguard/wolfi-base
14+
# Wolfi image with latest tag digest
15+
FROM cgr.dev/chainguard/wolfi-base@sha256:9608820b6ea4da8bcf16989dac37a280f8f1fa0022efc45b5ed4b1ac1f634a79
1616

1717
ARG version=3.12
1818

0 commit comments

Comments
 (0)