-
Notifications
You must be signed in to change notification settings - Fork 489
Multiarch images #432
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
base: master
Are you sure you want to change the base?
Multiarch images #432
Conversation
Hi @BowlesCR , Thank you for this PR. TL;DR : This is a substantial change. I have been reviewing it for a few days, and my current view is that, while a few items need adjustment, the proposal looks practical and on a good path. Proposal: run as a parallel test workflow firstTo minimize any risk to the published images, could we run this as a separate test workflow first? Please:
Optional:
If you would prefer, let me know and I can help finish these items. If this PR reaches a good state, Checklist to promote
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the two important items I would like to request:
- Use
.github/workflows/test.yml
and keep.github/workflows/main.yml
unchanged. - Use a test Docker Hub repository for images:
DOCKERHUB_REPO: postgis/postgis
->DOCKERHUB_REPO: postgis/docker-postgis-test
.
The rest is optional, and I can handle it if you prefer.
jobs: | ||
env: | ||
DOCKERHUB_REPO: postgis/postgis | ||
GITHUB_REPO: postgis/docker-postgis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(optional) add env : LATEST_VERSION: 17-3.5
- to define which build is tagged as latest, and implement the related tagging.
|
||
jobs: | ||
env: | ||
DOCKERHUB_REPO: postgis/postgis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to:
DOCKERHUB_REPO: postgis/docker-postgis-test
docker info -f '{{ .DriverStatus }}' | ||
- name: Load binfmt platforms for QEMU | ||
./official-images/test/run.sh -c ./official-images/test/config.sh -c test/postgis-config.sh ${{ steps.build.outputs.imageid }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(optional) backup the log ; and in the next step : Implement a CI check to ensure the official test output contains: ( 'postgis-basics' [6/6]...passed )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not familiar with this output, but the [6/6]
bit seems fragile -- I assume that would change with the number of test cases.
In your experience would it be reasonable to regex away the counts and rely on passed
?
- name: Checkout source | ||
uses: actions/checkout@v4 | ||
- name: Upload digests | ||
uses: actions/upload-artifact@v4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho: The workflow must never push or publish any artifacts, manifests, or Docker images during a Pull Request test run.
so please add :
if: ${{ (github.repository == env.GITHUB_REPO) && (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, this may be the gotcha I ran into before but forgot about. I'd have to come up to speed again but I remember something about attempting to adhere to the "no registery pushes during PRs" heuristic conflicting with "Need to do a non multiplatform image push to the registry first in order for the multiplatform image manifest creation to be possible" 😬 (but I may be wrong)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could certainly make PRs behave differently.
Do you care to have both architectures build on PR, or is either fine? If I recall, the current process doesn't yield anything someone can download, so either should be fine unless there's concern that something could break on only one arch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you care to have both architectures build on PR, or is either fine? If I recall, the current process doesn't yield anything someone can download, so either should be fine unless there's concern that something could break on only one arch.
I'm not sure if this answers your question, but ideally we'd want to have a PR trigger CI to build x86 image on an x86 runner and arm64 image on an arm64 runner (so that both builds happen natively from their own perspective) but the architecture of the runner that handles building the multiplatform manifest and potentially pushing the images/manifests to the registry is probably less of a concern.
- name: Upload digests | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: digests-${{ env.VERSION }}-${{ env.VARIANT }}-${{ matrix.runner-platform }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho: The workflow must be protected against parallel or consecutive runs causing artifact name collisions.
proposal add a ${{ github.run_id }}
name: digests-${{ github.run_id }}-${{ env.VERSION }}-${{ env.VARIANT }}-${{ matrix.runner-platform }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm missing your point, this should already be handled because the upload is implicitly scoped to the run in progress. Other runs (and even re-executing the same run) are isolated.
run: | | ||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
$(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(optional) imho: need an <DOCKERHUB_REPO>:latest
tag ; based on the the environment value LATEST_VERSION
One slight concern I thought of: As-is all the image variants are built before any merging happens though, so unless something goes sideways in the merge step there won't be a risk of mismatched tags. |
I understand that there might be dangling images in dockerhub, but I'm assuming they have have a garbage collection process that prunes out untagged images that may exist. I know github's ghcr.io doesn't have that GC and the untagged dangling images are shown in the repo's image list which is unfortunate 😅 but the dangling images don't show up on dockerhub as far as I've ever seen so I figured it was safe to assume there's some GC policy in the background that prunes them at some point. I'm not sure it's a priority concern for the purposes of this current task of getting the multiarch images going, so we could figure out how to prune down the road if it becomes necessary. |
As discussed briefly in #216
The high-level logic here is to build each postgres/postgis/variant tuple natively (for speed) on both AMD64 and ARM64 separately, then push those images to Dockerhub by digest (ie, untagged). Do some magic with manifests/indexes to reference those digest and push them up to Dockerhub with the human-readable tags.
When someone pulls the image, dockerd will follow the index/manifest chain to resolve the correct image for the runtime's architecture.
If this is merged, it probably obviates #256, #405, #406 (nonexhaustive)