pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.26k stars 626 forks source link

docker buildx bake support #21278

Open msavtchouk-pf opened 1 month ago

msavtchouk-pf commented 1 month ago

Is your feature request related to a problem? Please describe. We would like to use https://docs.docker.com/build/bake/ to make our docker build process more efficient. At the moment we are using pants+docker as described here: https://www.pantsbuild.org/blog/2021/10/13/pants-pex-and-docker

Describe the solution you'd like We would like pants to support docker bake, or alternative solution to parallelize builds + caching

Describe alternatives you've considered Alternative is not to use pants.

huonw commented 1 month ago

Thanks for filing a feature request.

Pants is entirely volunteer driven. Are you interested in contributing to extend the existing docker backend to support this?

If so, we can definitely try to provide guidance/mentorship!

lilatomic commented 1 week ago

Pants can currently build docker images in parallel if multiple docker target are specified (ex pants package :docker0 :docker1 or pants package ::)

docker buildx bake looks to be a serialisation of the arguments to the docker build. In that way it and Pants are performing the same tasks. One approach would be to use a Synthetic target generator to parse the bake file and generate docker_image targets from it. We'd want to tag them somehow as coming from a Bake file so we could invoke the correct build command. There's already (experimental) support for using podman and separately for using buildx, I wonder if it would make sense to broaden that support for docker buildx bake as well.