Does anyone have an example where `docker_image` i...
# general
Does anyone have an example where
is an dependency? Meaning that some other targets depend on a docker image. e.g. running tests using that image, building another image using it as a base image, etc.
Have you tried something and it’s not working as you expect?
In “Testing your packaging pipeline” there’s an example of using a packaged artefact. And towards the end of I think there’s examples of images depending on each other
Thank you, I saw this and its previous post, but both example have very simple Dockerfile just adding PEX. What is the good practice if docker build is slow (e.g. with many
apt-get install
)? I only want to rerun when necessary. A few options I can think of are 1. Single Dockerfile with separate layer and rely on docker build cache -> difficult to reuse cache in CI/CD and sometimes save/load are still slow when the final image is big. 2. Use pants caching: Two dockerfile,
adds some specific tag (e.g.
-t apt-installs-latest
) and the next
uses it (
FROM apt-installs-latest
). Pants dependency could be set so that building
depends on
. With
, it could skip building
if not changed. -> relying on tag seems brittle Any thoughts?
Pants doesn’t directly cache docker image layers at the moment, so relying on docker build cache is required either way, unfortunately. Some relevant issues if you want to track them:
👀 1
(With pants 2.16, potentially one could use the new `adhoc_tool`/`shell_command` to export the docker layers to something pants can cache, but getting them back into docker reliably seems hard… maybe combined with the new experimental environments feature too… but that seems very fiddly)
Thank you so much! The issues are very relevant. I’ll look into them more.