pantsbuild / pants

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

Support build of deterministic container images like Bazel #14657

Open chronicc opened 2 years ago

chronicc commented 2 years ago

Is your feature request related to a problem? Please describe. The traditional way of building container images is by using the docker build daemon. This way of building images causes all layers to be rebuild after a previous layer has been changed due to the information stored inside a layer. A layer knows which layer is directly in the order above it. Also the hash of a layer seems to be generated randomly.

Describe the solution you'd like Bazel solved the problem of having deterministic layers (and thus containers) by creating it's own way of building images. As far as I understand Bazel removes the connection to the upstream layer, thus removing the direct dependency. Also it generates a hash for the layer which is calculated from the exact contents of the layer leading to the same hash when the same layer is produced.

Bazel solves the ordering problem with the way, the build system orders the steps. Thus the dependency inside the layers is not necessary anymore.

Describe alternatives you've considered Up until now I did not find any alternative to Bazel which seems to be the only build system solving this problem.

Additional context A blog entry describing the problem from 2015: https://blog.bazel.build/2015/07/28/docker_build.html

Eric-Arellano commented 2 years ago

Hi, thanks for the feedback! I think this is similar to https://github.com/pantsbuild/pants/issues/14395 - could you please take a look and clarify if that would cover your concerns? If not, what would be missing from #14395?

chronicc commented 2 years ago

Hi, implementing a feature mimicking the way bazel builds container images, would fulfill the goals of both tickets. However in #14395 bazel is one of many options to solve the request. If you decide to implement a bazel-style way, then this issue here is obsolete.