https://pantsbuild.org/ logo
#general
Title
# general
c

cold-vr-15232

05/09/2023, 9:04 AM
Am I doing something wrong, or is it as designed that running "pants package ::" will rebuild all docker images, even if there has been no change in their dependecies?
h

high-magician-46188

05/09/2023, 9:25 AM
Subscribing to hear the response 🙂
b

broad-processor-92400

05/09/2023, 10:31 AM
Unfortunately, I think this is a limitation of pants at the moment i.e. you're not doing anything wrong. Pants caching is focused on, AIUI, the files that processes output, and so external commands like "tell docker to build an image" can't easily be cached. For our docker builds, docker's cache does meant that later builds are faster, even if pants is forced to run them still. https://github.com/pantsbuild/pants/issues/18287 is a relevant issue.
c

cold-vr-15232

05/09/2023, 10:55 AM
Ok, thanks for the info!
h

happy-kitchen-89482

05/09/2023, 12:36 PM
Pants caches based on the input files, but even if those never change, you could have deleted the image from your local docker state, so Pants purposely doesn't cache those runs: https://github.com/pantsbuild/pants/blob/3f7bea43ea1383400de2727becf024af82692b6e/src/python/pants/backend/docker/util_rules/docker_binary.py#L90
So yes, by design
w

wonderful-boots-93625

05/09/2023, 6:23 PM
Is this also true for pretty much any output type? Or just docker? E.g. I could have just as easily moved files around from
dist
b

broad-processor-92400

05/09/2023, 6:36 PM
Yeah, you’re right, it’s a matter of complexity/speed, I think: rerunning goals like package will always re-copy the outputs out of pants internal cache, to get dist to the right state (as you say, someone might have mutated it) Docker is similar, just the action required for “get external system to the right state” is more complicated than copying files: it’s “do a docker build”.
👆 1
3 Views