Speedup docker build in CI#723
Open
evgeny-stakewise wants to merge 4 commits into
Open
Conversation
Comment on lines
7
to
+91
| @@ -35,20 +43,87 @@ jobs: | |||
| with: | |||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |||
| - name: Build and push | |||
| - name: Build and push by digest | |||
| id: build | |||
| uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5 | |||
| with: | |||
| context: . | |||
| push: ${{ github.event_name != 'pull_request' }} | |||
| tags: ${{ steps.meta.outputs.tags }} | |||
| platforms: ${{ matrix.platform }} | |||
| labels: ${{ steps.meta.outputs.labels }} | |||
| platforms: linux/amd64,linux/arm64 | |||
| cache-from: type=gha | |||
| cache-to: type=gha,mode=max | |||
| outputs: type=image,"name=europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator,stakewiselabs/v3-operator",push-by-digest=true,name-canonical=true,push=true | |||
| cache-from: type=gha,scope=${{ matrix.platform }} | |||
| cache-to: type=gha,mode=max,scope=${{ matrix.platform }} | |||
| - name: Export digest | |||
| run: | | |||
| mkdir -p /tmp/digests | |||
| digest="${{ steps.build.outputs.digest }}" | |||
| touch "/tmp/digests/${digest#sha256:}" | |||
| - name: Upload digest | |||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |||
| with: | |||
| name: digests-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} | |||
| path: /tmp/digests/* | |||
| if-no-files-found: error | |||
| retention-days: 1 | |||
|
|
|||
| docker-merge: | |||
| name: Merge Docker Manifests | |||
| needs: docker | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| - name: Download digests | |||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |||
| with: | |||
| path: /tmp/digests | |||
| pattern: digests-* | |||
| merge-multiple: true | |||
| - name: Docker meta | |||
| id: meta | |||
| uses: docker/metadata-action@b2391d37b4157fa4aa2e118d643f417910ff3242 # v3 | |||
| with: | |||
| images: | | |||
| europe-west4-docker.pkg.dev/stakewiselabs/public/v3-operator | |||
| stakewiselabs/v3-operator | |||
| flavor: | | |||
| latest=auto | |||
| tags: | | |||
| type=ref,event=branch | |||
| type=ref,event=tag | |||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Docker GitHub Actions workflow to reduce CI build time by building amd64 and arm64 images in parallel on architecture-appropriate runners, then merging them into multi-arch manifests.
Changes:
- Convert the Docker build job into a matrix that builds/pushes per-platform images by digest on separate runners.
- Add a follow-up job to download per-platform digests and create/push multi-arch manifests for both GAR and Docker Hub.
- Update the Trivy scan job to wait for the manifest-merge job instead of the per-platform build job.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.