Caching docker targets - looks like pants is alway...
# general
a
Caching docker targets - looks like pants is always re-running the
docker build ...
command upon
pants package some_docker
even if no dependencies of this target were changed. I understand that this is a current limitation with the use of external tools with pants, but i'm perfectly fine with making pants a bit "less hermetic" in this case. Namely - if the dependencies did not change, do not run the
docker build ...
command, and just assume the output already exists. Is there a way to achieve that?
c
unfortunately not without modifying the docker backend. if you’re really eager to do this, you could fork the docker backend and provide it as a custom plugin and modify it to do that, by changing the cache scope here: https://github.com/pantsbuild/pants/blob/594f4372256ee19471f0a76c197e2b42c49e1f9e/src/python/pants/backend/docker/util_rules/docker_binary.py#L[…]91
or monkey patching
h
Bazel gets around this by not using the docker tooling at all. Just builds images manually. I found it much less approachable. But just some insight on how others do it
👍 2
c
I guess you’re slightly more limited in the images you build then too? like only add content layers, no
RUN
instructions etc..?
h
I believe the way they handle that is effectively running things elsewhere, zipping it up, and then adding it as a layer in the final image.
But it’s been quite a while since I poked in that area
f
In my experience trying to break down how image layers get built like that results in a lot of time wasted zipping copying around layers between different storage backends. I think it's okay to open up small cracks in hermeticity as a compromise, as long as they are limited in number and scope and we highlight them and make them optional