fix(docker): multi-arch image build (amd64+arm64) -- closes #223#445
Open
TheAuditorTool wants to merge 1 commit intoOWASP-Benchmark:masterfrom
Open
fix(docker): multi-arch image build (amd64+arm64) -- closes #223#445TheAuditorTool wants to merge 1 commit intoOWASP-Benchmark:masterfrom
TheAuditorTool wants to merge 1 commit intoOWASP-Benchmark:masterfrom
Conversation
…chmark#223 The published Docker image was linux/arm64 only because it was built on an ARM64 host. This caused >60s startup via QEMU emulation on amd64, breaking downstream CI (ZAP scans). Changes: - VMs/buildDockerImage.sh: rewrite to use docker buildx with --platform linux/amd64,linux/arm64 for multi-arch manifest - VMs/Dockerfile: pin ubuntu:22.04, collapse RUN layers, add EXPOSE 8443 and CMD for usability - .github/workflows/docker-publish.yml: add CI workflow for automated multi-arch builds (workflow_dispatch only -- inactive until secrets and triggers are configured) - PR_multi-arch-docker.md: changelog, guide, and activation steps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The published Docker image was linux/arm64 only because it was built on an ARM64 host. This caused >60s startup via QEMU emulation on amd64, breaking downstream CI (ZAP scans).
Changes:
Summary
The published
owasp/benchmark:latestDocker image was built on an ARM64 host,making it linux/arm64 only. On amd64 machines (the vast majority of CI runners
and developer workstations), Docker falls back to QEMU emulation, causing
startup times over 60 seconds -- long enough to break downstream CI (e.g., ZAP
scans reported in #223).
This PR switches the build tooling from
docker buildtodocker buildx buildwith
--platform linux/amd64,linux/arm64. Docker Hub receives a single manifestlist that serves the native image for each architecture automatically.
What Changed
VMs/DockerfileFROM ubuntu:latest->FROM ubuntu:22.04latestsilently rolls forward and has caused breakage before.RUN apt-getlayers into 1RUNalso ensuresapt-get updateandinstallshare the same cache.rm -rf /var/lib/apt/lists/*RUNRUNuseradd+chpasswdinto 1RUNEXPOSE 8443CMD ["./runBenchmark.sh"]useraddlineVMs/buildDockerImage.shComplete rewrite. The old script ran
docker build -t benchmark .whichproduces a single-architecture image matching the build host.
The new script:
docker buildxbuilder instance namedbenchmark-multiarch.docker buildx build --platform linux/amd64,linux/arm64 --pushwhichbuilds for both architectures and pushes a manifest list to Docker Hub in
one atomic step.
Important:
--pushis required because multi-arch manifest lists cannot beloaded into the local Docker daemon. The build and push happen together.
.github/workflows/docker-publish.yml(NEW -- INACTIVE)A GitHub Actions workflow that automates the multi-arch build and push.
This workflow is set to
workflow_dispatchonly -- it will never runautomatically until you activate it. See the activation section below.
How to Use the Build Script (Manual Build)
Prerequisites: Docker with buildx support (Docker Desktop 19.03+ or Docker
Engine with the buildx plugin). You must be logged in to Docker Hub:
Then, from the
VMs/directory:cd VMs ./buildDockerImage.shThis builds for both amd64 and arm64 and pushes
owasp/benchmark:latesttoDocker Hub. No separate
docker pushstep is needed.How to Activate the GitHub Actions Workflow
The workflow file is already in place at
.github/workflows/docker-publish.yml, but it will only run when manuallytriggered via the GitHub UI. To make it fully automatic:
Step 1: Add Docker Hub Secrets
Go to Settings > Secrets and variables > Actions in your GitHub repository
and add:
DOCKERHUB_USERNAMEDOCKERHUB_TOKENStep 2: Add Automatic Triggers
Open
.github/workflows/docker-publish.ymland uncomment the trigger lines:This will automatically rebuild and push the image whenever:
Step 3: Test with Manual Trigger
Before enabling automatic triggers, test the workflow manually:
You can confirm multi-arch support with:
This should show entries for both
amd64andarm64.What Was NOT Changed
bench:benchuser/passwordtimeout 60 ./runBenchmark.sh; exit 0warm-up trick