:wave: Hi I’m interested in addressing a docker/bu...
# development
f
👋 Hi I’m interested in addressing a docker/buildx issue 19994 but need some guidance on what a proper fix would actually look like. Theres a lot more context in this thread on the specifics of the problem, but it boils down to I’d like
pants package
and
pants publish
to be semantically correct for cross platform docker builds when using buildx. buildx makes that awkward by forcing the use of a single command to both package and publish in a single step https://pantsbuild.slack.com/archives/C046T6T9U/p1711423114773989?thread_ts=1711401515.193319&cid=C046T6T9U
c
Hi! 👋 Awesome to get this addressed. I'll drop a few thoughts/ideas/notes on what I think this could look like, for inspiration. (caveat: I've not used Docker for a long time, so the whole buildx thing is new territory for me, so my ideas are merely guided by old knowledge and the various tidbits provided in the comments here about how it works..) First, I would prefer it if we can avoid adding dedicated targets to solve this; which I think we can. I read the comment about building a simplified (single platform) image for testing (that would be when using
pants package
) and then building (and pushing) the multi platform image when doing
pants publish
. To me this makes sense, and is what I'll go for in my following notes.. Notes: • Tweak
pants package
to only build for the local platform when using buildx (i.e. ignore the build_platforms field; anything else?) • Split the
build_docker_image
rule so the we can re-use the part of getting the
Process
request for building the image as a rule helper. • For
pants publish
when using buildx, use the build image rule helper to get the
Process
request for building, providing a flag to indicate we want to build for and push, a multi platform image. I think that's pretty much it at a high level. Thoughts?
f
That all makes sense to me, I’ll put together a draft so we can have a reference point to talk about
🙌 1
n
I think a draft would definitely be helpful. If i'm understanding this correctly, this is all for the case where we don't want to use the containerd-snapshotter, which is currently the happy path for Pants-docker-buildx currently? I think
pants package
should build for the platforms specified when run locally - that is a feature of buildx - to support building images for different platforms locally? Another option might be to export the images to file (output type = 'image' from memory? ) and push them from there with publish? But I do like the suggestion of having
publish
do build and publish in the case of buildx - probably makes things simpler in terms of publish not having to expect already built images laying around somewhere.
f
I’ve got a very rough draft ready to discuss https://github.com/pantsbuild/pants/pull/20728
👍 1