cool-easter-32542
09/22/2023, 2:40 PMdocker buildx to build containers, specifically for the following features:
1. --cache-from and --cache-to support
2. Custom builder instances using the kubernetes driver
We lost both features when we started using pants to build our images. The need for custom k8s-based builders is less urgent on our end because we can achieve a ~similar result by self-hosting GHA runners, but the lack of more advanced caching options has been painful when building more-heavyweight images. We run on ephemeral GHA runners so the local docker cache gets blown away after each run (we've tried persistent runners to address this, but hit other issues with leftover state between jobs causing inconsistent behavior).
Describe the solution you'd like
At a minimum, I'd like to be able to specify --cache-from and --cache-to for docker builds in pants.
• --cache-from is already a valid option in vanilla docker build, but I think the syntax it expects is different than in docker buildx build.
• --cache-to is a docker buildx build-only option.
Less important but nice-to-have would be ensuring the use of custom buildx builders works. I don't think pants should/could worry about setting up the builders itself - I do think that if somebody sets up a custom builder before calling ./pants, the sandbox would ideally contain all the config files needed to use it.
Describe alternatives you've considered
• Only use pants up to the point of building PEX files, and build containers outside of the system using docker buildx directly
• Would have to reinvent the wheel to figure out which docker images had dependencies that changed, not feasible
• Use docker buildx install to make docker build an alias for docker buildx build, and see if there's a way to set values for --cache-from and --cache-to via env vars
• As far as I've seen, setting options via the environment isn't supported
pantsbuild/pantscool-easter-32542
09/22/2023, 2:40 PM