bazelbuild / rules_docker

Rules for building and handling Docker images with Bazel
Apache License 2.0
1.07k stars 692 forks source link

Add fully-qualified naming to `container_image` targets #1962

Closed psigen closed 1 year ago

psigen commented 2 years ago

🚀 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

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

hxtk commented 2 years ago

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

psigen commented 2 years ago

Thanks @hxtk, updated.

github-actions[bot] commented 2 years ago

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!

psigen commented 2 years ago

Hmm, I still want this feature, maybe I will try to make a PR...

github-actions[bot] commented 1 year ago

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!

github-actions[bot] commented 1 year ago

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"