curved-television-6568
11/09/2021, 10:04 PMhundreds-father-404
11/09/2021, 10:14 PMhundreds-father-404
11/09/2021, 10:15 PMhundreds-father-404
11/09/2021, 10:16 PMhundreds-father-404
11/09/2021, 10:22 PMdockerfile
target that gets coupled to a docker_image
target?
That was my least favorite option because of the coupling, but willing to keep an open mind
Question: would you anticipate it every not being a 1:1 relationship? E.g. that multiple docker_image
targets use the same dockerfile
?happy-kitchen-89482
11/09/2021, 11:11 PMcurved-television-6568
11/10/2021, 6:02 AMupdate the PR description with what we discussed for the motivation: really this change is about unblocking target generators for DockerfilesThe PR already says:
In order to support building Docker images without a dedicatedÂIt’s not clear to me what to update here.. on disk, theÂDockerfile
 target has a codegen rule that creates theÂdockerfile
 on demand.Dockerfile
curved-television-6568
11/10/2021, 6:05 AMyou’re suggesting we go with Option B? AÂYes, that is what I (and [also Benjy](https://github.com/pantsbuild/pants/pull/13386#discussion_r742223057) ) suggested. target that gets coupled to aÂdockerfile
 target?docker_image
curved-television-6568
11/10/2021, 6:11 AMThat was my least favorite option because of the couplingI don’t really see what’s bad with this coupling.. ? From my point of view, the
dockerfile
target represents its own thing, the “Dockerfile”. When it does not exist on disk so we can reference it with the source
field of the docker_image
we can create one with the codegen target instead and add it as a dependency. The docker_image
target describes our image, not the Dockerfile. That’s my main motivation for not simply introducing the instructions
field directly on the docker_image
target. (Which would be option C).curved-television-6568
11/10/2021, 6:13 AMQ: would you anticipate it every not being a 1:1 relationship? E.g. that multipleÂThat may very well be the case. Not something that I’ve designed for, but as you may write a generic Dockerfile using build args, you could certainly use the same targets use the sameÂdocker_image
?dockerfile
dockerfile
with multiple docker_image
targets with different build arguments.curved-television-6568
11/10/2021, 6:26 AMsource="Dockerfile"
when using a file from the workspace.
Would love to solve this somehow.. but introducing another target next to docker_image
solely for this reason feels a bit too much, for me. (For reasons outlined above, being that it is not an alternative for docker_image
we need, but for the Dockerfile
). Hence why it is really hard to come up with a sensible name for this secondary target.curved-television-6568
11/10/2021, 8:46 AMdockerfile
support using either the instructions
field to generate the Dockerfile or use the source
field to use a file from disk.
With this addition, a docker_image
target may generate a dockerfile(source="Dockerfile")
target and inject a dependency on that, in order to preserve the default behaviour. It may feel a bit clumsy, but this should all be implementation details. In case there is no “Dockerfile” on disk, the error message will be slightly different from when the default was from the source field on the docker_image target, but that would be all.
In the end, I think I like the idea of promoting the Dockerfile to a distinct target to work with, separate from the docker_image
target.curved-television-6568
11/10/2021, 8:49 AM# still supported
docker_image(source="CustomDockerfile", ...)
# explicit dep
docker_image(dependencies=[":dockerfile_tgt"], ...)
# either of these
dockerfile(name="dockerfile_tgt", instructions=[...])
dockerfile(name="dockerfile_tgt", source="CustomDockerfile")
# Default
docker_image(
name="MyImage",
# injected dep
dependencies=[":MyImage#Dockerfile"]
)
# generated target by docker_image
dockerfile(name="MyImage#Dockerfile", source="Dockerfile")
happy-kitchen-89482
11/10/2021, 8:51 AMdocker_image()
in that directory works. I don't expect instructions
to be that commonly used, at least when adopting Pants, so I'd rather optimize for the common case.happy-kitchen-89482
11/10/2021, 8:51 AMinstructions
and source
directly on docker_image
?curved-television-6568
11/10/2021, 8:52 AMdockerfile
target as a stand alone construct doesn’t add much value any more.curved-television-6568
11/10/2021, 8:54 AMsource
in that case.. Or, we simply require to set source=""
if using the instructions
field..?curved-television-6568
11/10/2021, 8:55 AMhappy-kitchen-89482
11/10/2021, 8:56 AMhappy-kitchen-89482
11/10/2021, 8:56 AMhappy-kitchen-89482
11/10/2021, 8:56 AMcurved-television-6568
11/10/2021, 8:57 AMexpected_num_files
on a source field.curved-television-6568
11/10/2021, 9:09 AMcurved-television-6568
11/10/2021, 9:30 PMcurved-television-6568
11/10/2021, 9:30 PMcurved-television-6568
11/12/2021, 11:54 AM