rules_docker
rules_docker copied to clipboard
Add fully-qualified naming to `container_image` targets
🚀 feature request
Relevant Rules
Affects container_image and derivative *_image rules.
Description
Suppose I have two completely unrelated workspaces with different names: com_example_A and com_example_B. In each one, I create a container_image target:
container_image(
name = "helloworld",
...
)
These workspaces have nothing to do with each other. However, by default, when I try to load their respective images:
bazel run //:hello_world --norun
they will be loaded to the same repository name: bazel/hello_world.
This can wreak havoc on shared build machines or any case where a user is working with two workspaces. I ran into this situation in a build farm where two unrelated workspace build jobs generated the same named image and one ended up tagging the wrong one in the middle of a build script.
Describe the solution you'd like
- Add a flag to
container_imagelikeuse_qualified_name=Truethat allows switching the repository name to include the workspace name, e.g.bazel/com_example_A/helloworldandbazel/com_example_B/helloworld. - Encourage users to use these fully qualified repository names
- Eventually change the default for the flag to use fully qualified image names
Describe alternatives you've considered
What I am doing right now, which is fairly painful, is manually setting the repository param for every container_image target in my workspace. This works, but is difficult to maintain and error prone.
https://github.com/bazelbuild/rules_docker/blob/8f6a2aa6e906f518603848a59917d46c972ce99e/container/image.bzl#L737-L746
You may want to target a particular commit in your link rather than the head of the master branch. Currently it does not point to a coherent unit of functionality, beginning part-way through one multi-line string literal and ending part-way through another. The contents of that file has drifted since your original submission.
Here's the link to that same range of lines, pinned to the latest commit at the time you submitted this issue:
https://github.com/bazelbuild/rules_docker/blob/8f6a2aa6e906f518603848a59917d46c972ce99e/container/image.bzl#L737-L746
Thanks @hxtk, updated.
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!
Hmm, I still want this feature, maybe I will try to make a PR...
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"