My last question for the day: Do `docker_image` ta...
# general
My last question for the day: Do
targets only support dependency inference on paths that "look like" the outputs of
targets? Or, can you directly put target addresses anywhere in the Dockerfile and have the dependency inference work? So if, for example I had a Dockerfile with:
Copy code
FROM path/to/my/parent/docker/image:target

RUN pip install path/to/a/python_distribution:target
Would pants infer the dependency on both the parent docker image and the python package automatically, and inject the output paths for those targets into the build context automatically? I'm digging through the source code now but I honestly can't really figure out if it supports anything beyond
FROM target_address
COPY output_path_that_can_be_mapped_to_a_target
Let me check
Looks like it's just FROM and COPY, as you thought.
But it would be straightforward to add inference on other commands, if it made sense to do so
Note that it's not just
targets you can infer deps on, but any target that is "packageable" (i.e., that
./pants package
applies to)
But now that I think of it, you'd have to COPY anything useful into the image before you could RUN it, no?
I did not know it infers
. Is that really true as I cannot find this to be documented? What about
COPY --from=parent-image
It hasn’t found it’s way into the Docker section of the docs, but it is in the reference section for the
It’s for the
instruction only, not for the
COPY --from
That wouldn’t be too difficult to add, though. PRs welcome if so inclined 😉
Also, I notice the docs still refer to inference for
targets only, but it is now any packageable target not just pex ones.
👍 1
Great point about the
! And in the
lines, will it only infer dependencies if you embed a target address there? Or will it detect an image URI that's in one of the image registries set up in your config, then search your repo for other
targets that package and publish an image to the registry and image tag in the
line and infer a dependency on the matching
target automatically?
Ah, doesn't seem to work like that from some quick local testing. I'm still trying to get my head wrapped around the plugin API and the docker backend implementation, but from reading through the pants source code this doesn't seem like it would be too painful to add would it?