Skip to content
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

Container image build for ARM + semantic tags #386

Merged
merged 23 commits into from
Feb 15, 2024
Merged

Container image build for ARM + semantic tags #386

merged 23 commits into from
Feb 15, 2024

Conversation

rhtenhove
Copy link
Contributor

@rhtenhove rhtenhove commented Feb 14, 2024

Wanting to use your tool on an ARM machine using the container image was impossible (without building my own image) because currently it only builds for amd64. Trying to add ARM made me realize the container image build process was much too complex.

So this PR moves everything-container to a separate workflow file, and attempts to greatly simplify it, while adding awesome features. These are:

  • Uses Docker Buildx & QEMU to build for both amd64 and arm64. More platforms can easily be added if so desired.
  • Multiple architectures are pushed to the same tag, ensuring the user will pull the correct image using the same tag on different architectures
  • Adds tags to be able to pin on major or minor versions (such as ghcr.io/tomwright/dasel:2-alpine) to follow development while preventing breaking changes. This assumes you ensure no breaking changes are introduced within a major version.
  • dasel is now built within the container image build process, so the OS and architecture will always match the container

This introduces some changes which are important to be aware of

  • There is now a single Dockerfile which uses variables to either target debian (default) or alpine (or other OSes if so desired).
  • This process is run on every event, however the multiple architectures build, versioned tags creation, and pushing to the registry only happens when a tag which starts with v is pushed. Furthermore, a version parsing step ensures only semantic version tags get pushed to the registry.
  • The container tagging uses the convention seen on image registry which is version tags without the v. It does however keep the vx.x.x just as you pushed the images before. These tags all reference the same image, so they won't take up any resources other than a pointer.
  • I've made the default CMD --help so when the container is run without any arguments, the help is shown. I don't believe there are any scenarios where having no arguments will be useful, but I may be wrong.

All steps have been tested, except for the registry authentication and pushing to that registry as only you have access to that.

@TomWright
Copy link
Owner

Hey @rhtenhove, thanks a lot for these improvements!

The docker setup has always bugged me but I've never quite found the time to come back to it and sort it out. Really appreciate the work here.

I've had a look through and don't see anything concerning so I say lets do it. Once I have some time (probably tonight) I'll come back to this, merge and release a new version to make sure all is working as expected.

@TomWright TomWright merged commit e1cef9d into TomWright:master Feb 15, 2024
14 checks passed
@TomWright
Copy link
Owner

@rhtenhove I've made a release and things look good from a first glance:
image

@rhtenhove
Copy link
Contributor Author

Awesome! Just gave it a go on an ARM machine, and it works perfectly fine!

~> docker run --rm --entrypoint "" ghcr.io/tomwright/dasel:2-alpine sh -c "uname -a && dasel --help"
Linux 2d2b6311abe2 5.15.0-94-generic #104-Ubuntu SMP Tue Jan 9 15:26:57 UTC 2024 aarch64 Linux
Select properties from the given file.

Usage:
  dasel -f <file> -r <json,yaml,toml,xml,csv> <selector> [flags]
  dasel [command]
...

Just noticed ghcr shows the architecture unknown/unknown which appears to be a bug. You can add the workaround to remove it, up to you 😊 it has no functional impact.

Thanks for merging! Glad I can now use the container on ARM!

@TomWright
Copy link
Owner

Thanks for the info, I'll put it on my todo list 😄
Thanks again for the effort, much appreciated.

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.

None yet

2 participants