Skip to content

improve docker builds#258

Closed
thaddeuskkr wants to merge 7 commits intoPhineas:mainfrom
thaddeuskkr:main
Closed

improve docker builds#258
thaddeuskkr wants to merge 7 commits intoPhineas:mainfrom
thaddeuskkr:main

Conversation

@thaddeuskkr
Copy link
Copy Markdown

@thaddeuskkr thaddeuskkr commented Apr 21, 2025

this PR improves the current docker build workflow, does the following:

  • pushes image for testing on pull requests (tags with pr-[id] and commit sha (short), e.g., pr-32, etc.)
  • builds multiarch images using docker bake (currently set to linux/amd64 and linux/arm64, can be customised in docker-bake.hcl)
  • builds arm64 images using specific github hosted runners, builds all platforms simultaneously using matrixes
  • tags images with commit sha and branch rather than just latest, allows users to rollback changes themselves

this pull request will fix issue #244

sorry, i don't really have a way to test this specific workflow file cause of github secrets, but i do have a version with my own credentials

if anyone wants to test the built image, you can docker pull ghcr.io/thaddeuskkr/lanyard:selfbuilt

https://github.com/thaddeuskkr/lanyard/tree/selfbuilt

Signed-off-by: Thaddeus Kuah <tk@tkkr.dev>
Signed-off-by: Thaddeus Kuah <tk@tkkr.dev>
Signed-off-by: Thaddeus Kuah <tk@tkkr.dev>
Copy link
Copy Markdown
Contributor

@pxseu pxseu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaddeuskkr
Copy link
Copy Markdown
Author

I do see an issue here - which is that GitHub doesn't allow workflows run on pull requests access to GitHub Secrets (because workflow PRs can be used to retrieve / display secrets) - meaning all PR builds will fail, as they can't log in to Docker. To get around this, the login step can be skipped on PRs, but this also means that PR builds won't be pushed to the registry. I'll make a commit that does this.

Signed-off-by: Thaddeus Kuah <tk@tkkr.dev>
Signed-off-by: Thaddeus Kuah <tk@tkkr.dev>
Signed-off-by: Thaddeus Kuah <tk@tkkr.dev>
@thaddeuskkr
Copy link
Copy Markdown
Author

thaddeuskkr commented Apr 29, 2025

These changes should skip pushing the image to Docker Hub on PRs. This should mean that PR workflows can run and image building can be tested, but no changes will be pushed, and the images from the different architectures won't be merged.

This is the PR I used to test the workflow's pull_request event: https://github.com/thaddeuskkr/lanyard/pull/4
And the branch I'm building from (using GitHub Secrets as well for better testing): https://github.com/thaddeuskkr/lanyard/tree/selfbuilt
And the Docker Hub image that was built from that branch: https://hub.docker.com/r/thadkkr/lanyard (docker pull docker.io/thadkkr/lanyard:selfbuilt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants