cool-easter-32542
06/07/2025, 3:42 PM{pants.hash}, but it's not clear how it can help. My goal is to avoid building a given image if it didn't change, so ideally I'd like to:
• retrieve a hash for an image that I have in the registry
• retrieve a hash that corresponds to the revision of the code base where my Dockerfile and file dependencies are stored
• if the hashes match, do nothing. If they don't match, rebuild and push
I thought that the hash can be calculated statically, i. e. just by giving Pants the target, so that Pants can take a look at files and base images contributing to a given image, and calculate the hash. However, so far it looks like the hash is accessible to the user only after a successful build of an image, so that I can tag the image using the hash and that's it. A feature is missing to retrieve the hash prior to building the image.
Describe the solution you'd like
Ideally Pants would be able to calculate the hash based solely on the contents of the repo, and without running Docker. There may be some edge cases, like using base images' digests in the hash - to be discussed how we should treat these.
Describe alternatives you've considered
Not clear if there's any viable alternative other than Pants-native build avoidance.
Additional context
Slack threads:
• https://pantsbuild.slack.com/archives/C046T6T9U/p1745401350333109?thread_ts=1745401350.333109&cid=C046T6T9U
• https://pantsbuild.slack.com/archives/C046T6T9U/p1744210991104779?thread_ts=1744210991.104779&cid=C046T6T9U
• https://pantsbuild.slack.com/archives/C046T6T9U/p1748940781635959?thread_ts=1748940781.635959&cid=C046T6T9U
pantsbuild/pants