-
Notifications
You must be signed in to change notification settings - Fork 29
feat: docker multi-arch reusable workflow #1348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ricky-undeadcoders
merged 23 commits into
main
from
rwhitaker/multi-arch-shared-workflow
Oct 21, 2025
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
02c4815
docker-build-push-multiarch initial commit
ricky-undeadcoders 1f88d59
Docs updates for docker-build-push-multiarch
ricky-undeadcoders 6676b64
update to point to new composite action branch
ricky-undeadcoders 50d38af
Convert merge-digest to run when push is false (handled in action)
ricky-undeadcoders ff71e87
remove delete-credentials-file input
ricky-undeadcoders 5da7873
Readme link updates
ricky-undeadcoders b8fc9ed
Update inputs to match downstream docker-build-push-image composite a…
ricky-undeadcoders 079fa9a
Update help text and platform mapping strategy for docker-build-push-…
ricky-undeadcoders d115ea5
Update help text and platform mapping strategy for docker-build-push-…
ricky-undeadcoders cea52cc
Update help text and platform mapping strategy for docker-build-push-…
ricky-undeadcoders 6db513e
Update help text and platform mapping strategy for docker-build-push-…
ricky-undeadcoders c5804b6
Update help text and platform mapping strategy for docker-build-push-…
ricky-undeadcoders 6423d07
Update help text and platform mapping strategy for docker-build-push-…
ricky-undeadcoders 0905834
Update help text and platform mapping strategy for docker-build-push-…
ricky-undeadcoders 96a5335
Update help text and platform mapping strategy for docker-build-push-…
ricky-undeadcoders f372797
Update help text and platform mapping strategy for docker-build-push-…
ricky-undeadcoders 757331f
Fix missing metadata in docker-import-digests-push-manifest
ricky-undeadcoders ff28a38
apply recommended changes
ricky-undeadcoders 5ed9d1c
add spellcheck disable
ricky-undeadcoders 9f72d18
update docs
ricky-undeadcoders f927b01
Fix composite action references
ricky-undeadcoders bc10c94
pin docker action shas
ricky-undeadcoders c0d5807
remove pre and post build steps
ricky-undeadcoders File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# docker-build-push-multiaarch | ||
|
||
This is a reusable workflow that uses Grafana's hosted runners to natively build and push multi-architecture docker | ||
images. | ||
|
||
Right now this supports pushing images to: | ||
|
||
- Google Artifact Registry | ||
- DockerHub | ||
|
||
And supports building the following image types: | ||
|
||
- linux/arm64 | ||
- linux/amd64 | ||
|
||
## How it works | ||
|
||
This generates a matrix based off of the `platforms` input, then creates a job per platform that runs the composite | ||
actions [docker-build-push-image] and [docker-export-digest] to build and push docker images, and capture their digests. | ||
There is then a final job that runs the composite action [docker-import-digests-push-manifest] to push the docker | ||
manifest. | ||
|
||
[docker/build-push-action]: https://github.com/docker/build-push-action | ||
[docker-build-push-image]: ../../docker-build-push-image/README.md | ||
[docker-export-digest]: ../../docker-export-digest/README.md | ||
[docker-import-digests-push-manifest]: ../../docker-import-digests-push-manifest/README.md | ||
|
||
<!-- x-release-please-start-version --> | ||
|
||
```yaml | ||
name: Build and Push and Push MultiArch | ||
|
||
on: push | ||
|
||
jobs: | ||
build-push-multiarch: | ||
uses: grafana/shared-workflows/.github/workflows/build-and-push-docker-multiarch.yml@rwhitaker/multi-arch-builds # TODO: Pin to version | ||
with: | ||
platforms: linux/arm64,linux/amd64 | ||
tags: | | ||
${{ github.sha }} | ||
rickytest | ||
push: true | ||
registries: "gar,dockerhub" | ||
pre-build-script: scripts/ci-build.sh | ||
``` | ||
|
||
<!-- x-release-please-end-version --> | ||
|
||
## Inputs | ||
|
||
| Name | Type | Description | | ||
| ----------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `build-args` | string | List of arguments necessary for the Docker image to be built. Passed to `docker/build-push-action`. | | ||
| `build-contexts` | string | List of additional build contexts (e.g., name=path). Passed to `docker/build-push-action`. | | ||
| `buildkitd-config` | string | The buildkitd config file to use. Defaults to `/etc/buildkitd.toml` if you're using Grafana's self-hosted runners. Passed to `docker/setup-buildx-action`. | | ||
| `buildkitd-config-inline` | string | The buildkitd inline config to use. Passed to `docker/setup-buildx-action`. | | ||
| `cache-from` | string | Where cache should be fetched from. Passed to `docker/build-push-action`. | | ||
| `cache-to` | string | Where cache should be stored to. Passed to `docker/build-push-action`. | | ||
| `context` | string | Path to the Docker build context. Passed to `docker/build-push-action`. | | ||
| `docker-buildx-driver` | string | The driver to use for Docker Buildx. Passed to `docker/setup-buildx-action`. | | ||
| `dockerhub-registry` | string | DockerHub Registry to store docker images in. | | ||
| `dockerhub-repository` | string | DockerHub Repository to store docker images in. Default: github.repository | | ||
| `file` | string | The dockerfile to use. Passed to `docker/build-push-action`. | | ||
| `gar-delete-credentials-file` | string | Delete the Google credentials file after the action is finished. If you want to keep the credentials file for a later step, set this to false. | | ||
| `gar-environment` | string | Environment for pushing artifacts (can be either dev or prod). This sets the GAR Project (gar-project) to either `grafanalabs-dev` or `grafanalabs-global`. | | ||
| `gar-image` | string | Name of the image to build. Default: `${GitHub Repo Name}`. | | ||
| `gar-registry` | string | Google Artifact Registry to store docker images in. | | ||
| `gar-repository` | string | Override the 'repo_name' used to construct the GAR repository name. Only necessary when the GAR includes a repo name that doesn't match the GitHub repo name. Default: `docker-${GitHub Repo Name}-${gar-environment}` | | ||
| `include-tags-in-push` | string | Disables the pushing of tags, and instead includes just a list of images as docker tags. Used when pushing docker digests instead of docker tags. | | ||
| `labels` | string | List of custom labels to add to the image as metadata (passed to `docker/build-push-action`). Passed to `docker/build-push-action`. | | ||
| `load` | string | Whether to load the built image into the local docker daemon (passed to `docker/build-push-action`). Passed to `docker/build-push-action`. | | ||
| `outputs` | string | List of docker output destinations. Passed to `docker/build-push-action`. | | ||
| `platforms` | string | List of platforms to build the image for. Passed to `docker/build-push-action`. | | ||
| `post-build-script` | string | A script to run after `docker build` | | ||
| `pre-build-script` | string | A script to run before `docker build` | | ||
| `push` | string | Whether to push the image to the configured registries. Passed to `docker/build-push-action`. | | ||
| `registries` | string | CSV list of registries to build images for. Accepted registries are "gar" and "dockerhub". | | ||
| `secrets` | string | Secrets to expose to the build. Only needed when authenticating to private repositories outside the repository in which the image is being built. Passed to `docker/build-push-action`. | | ||
| `server-size` | string | Size of the Grafana self-hosted runner | | ||
| `ssh` | string | List of SSH agent socket or keys to expose to the build Passed to `docker/build-push-action`. | | ||
| `tags` | string | List of Docker tags to be pushed. Passed to `docker/build-push-action`. | | ||
| `target` | string | Sets the target stage to build. Passed to `docker/build-push-action`. | | ||
|
||
## Outputs | ||
|
||
| Name | Type | Description | | ||
| --------------- | ------ | ------------------------------------------------------------------------ | | ||
| `annotations` | String | Generated annotations (from docker/metadata-action) | | ||
| `digest` | String | Image digest (from docker/build-push-action) | | ||
| `imageid` | String | Image ID (from docker/build-push-action) | | ||
| `images` | String | Comma separated list of the images that were built | | ||
| `json` | String | JSON output of tags and labels (from docker/metadata-action) | | ||
| `labels` | String | Generated Docker labels (from docker/metadata-action) | | ||
| `metadata` | String | Build result metadata (from docker/build-push-action) | | ||
| `runner_arches` | String | The list of OS used to build images (for mapping to self hosted runners) | | ||
| `tags` | String | Generated Docker tags (from docker/metadata-action) | | ||
| `version` | String | Generated Docker image version (from docker/metadata-action) | |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.