-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Dockerfile should use cross-compile when building for a different arch when possible #4560
Comments
This would inadvertently fix #4544 for me in a "benefits all default scaffold users" way without introducing maintenance overhead of introducing condition for a customized scaffold. |
Hi @kaovilai, Thank you very much for raising this issue and for your suggestions. As we discussed in GitHub Issue #4544 and in Slack, Kubebuilder provides two separate build targets to meet different needs:
I do not think we can cannot accept your request to add
|
That's not what I've seen in practice with podman alongside my colleagues. We have seen build speedup across the board. When Dockerfile lacks BUILDPLATFORM, Docker attempts to use QEMU-based emulation for a different arch build for every stages. |
My teammates uses podman everyday and do not have issues with |
podman also works here. :) What is the support scope of kubebuilder? How far back of older systems does kubebuilder needs to support? |
does projects using kubebuilder uses C/C++ libs? |
Hi @kaovilai, If we adopt your request, wouldn’t that require all users to use buildx?
Could you please let me know if https://github.com/kubernetes-sigs/kubebuilder/pull/4545/files will be accepted? Would it address your need, or would you still be looking to change the Dockerfile? Let me know your thoughts! |
Not in my experience, at least if you use podman, you will not require buildx. I have not validated for legacy docker for non native arch build. |
I guess #4545 would be ok for me, but to your point it's specific to our customization. At least from my team we would want to use BUILDPLATFORM everywhere including single arch because we spend a lot of time doing one of following
and when we give images to customers that's when we build for all arches. From our experience even for a single arch build, we do not experience deficiencies in performance when BUILDPLATFORM is included. And I have at least use this trick to fix an issue with CGO in replicatedhq/local-volume-provider#66 replicatedhq/local-volume-provider#65 (comment)
When BUILDPLATFORM is added, the segmentation fault goes away. |
I assume if kubebuilder adopts BUILDPLATFORM everywhere would be my preference but it is understandable if the expectation is to support C/C++ projects as part of kubebuilder default scaffold. |
Here is a quote from my testing back in August (RH slack)
My team saved a considerable amount of time building for single arch with BUILDPLATFORM. So to conclude, if the preference is for code to be applicable to everyone, I would push for kubebuilder to use BUILDPLATFORM by default everywhere for multi-stage build unless support for other requirements are blockers. I would agree to only keep these changes in our customized scaffolding otherwise. |
Legacy builder supports |
contrary to this statement, in docker docs,
|
What do you want to happen?
Dockerfile should use BUILDPLATFORM to cross build to reduce build time.
https://docs.docker.com/build/building/multi-platform/#cross-compilation
This is already seen used in docker-buildx target. We should refactor so that BUILDPLATFORM is used on all build Make targets, even for a single arch build.
Extra Labels
No response
The text was updated successfully, but these errors were encountered: