How do you copy a Python file when building a Dock...
# general
r
How do you copy a Python file when building a Docker image? I get this message:
Copy code
The following files were not found in the Docker build context:
  * src/python/some_package/some_file.py
h
you want it to show up as a loose file, right? THe answer is not very satisfying and @bitter-ability-32190 has been exploring how to improve it In the meantime, keep the
python_sources
targets, but also add a
file
target like this:
Copy code
file(
  name="some_file-file-tgt",
  source="some_file.py",
)
name
can be what you want. Then I think dependency inference should pick it up
b
Currently, the Docker plugin doesn't consider any
_source
target when constructing the sandbox. Generally it is assumed you'd be first packaging into a
pex_binary
. (FWIW I have a proposal hoping to shift the paradigm here)
h
Currently, the Docker plugin doesn't consider any _source target when constructing the sandbox.
It considers
file
targets
b
Right, that's not a
_source
target 🙈
r
Ha ok, I'll try the
file
target...
Thank you, adding a
file
target did the trick!
❤️ 1
h
Great! @rhythmic-glass-66959 any thoughts on how we could better document this? https://www.pantsbuild.org/docs/docker
r
Well, maybe add a warning admonition saying that the
python_sources
target won't work for copying Python files. And also, an example in the example-docker repository would be helpful.
👍 1