aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/build_defs/docker/docker.bzl
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-12-13 15:02:34 +0000
committerGravatar John Cater <jcater@google.com>2016-12-13 16:30:44 +0000
commit6b1d3184ac1c78439deac3c4f6d2531210fe34ce (patch)
tree20b43146c2881d53f6d27ed6f7a0af8b241494d0 /tools/build_defs/docker/docker.bzl
parentefb14117127789c0b0bc4670d4a92a44fbb3b4e4 (diff)
Switch to using multi-level repository names by default.
When these rules were originally written, I'd wanted the repository names embeded in the tarball to have a similar shape to Blaze's output trees, but unfortunately multi-level names were not yet supported. Support for multiple levels was introduced as part of the v2 registry specification, which is now all DockerHub supports, and the vast majority of clients in circulation support multi-level names. This change implements my original intention, which is to name the resulting image: bazel/{target}. To get the legacy naming system use the attribute: embed_flat_names=True. RELNOTES[INC]: docker_build: change the repository names embedded by docker_build. You can revert to the old behavior by setting legacy_repository_naming=True. -- PiperOrigin-RevId: 141886976 MOS_MIGRATED_REVID=141886976
Diffstat (limited to 'tools/build_defs/docker/docker.bzl')
-rw-r--r--tools/build_defs/docker/docker.bzl8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/build_defs/docker/docker.bzl b/tools/build_defs/docker/docker.bzl
index 5c59bac235..17773ba6d5 100644
--- a/tools/build_defs/docker/docker.bzl
+++ b/tools/build_defs/docker/docker.bzl
@@ -328,7 +328,12 @@ def _assemble_image(ctx, layers, name):
def _repository_name(ctx):
"""Compute the repository name for the current rule."""
- return "%s/%s" % (ctx.attr.repository, ctx.label.package.replace("/", "_"))
+ if ctx.attr.legacy_repository_naming:
+ # Legacy behavior, off by default.
+ return "%s/%s" % (ctx.attr.repository, ctx.label.package.replace("/", "_"))
+ # Newer Docker clients support multi-level names, which are a part of
+ # the v2 registry specification.
+ return "%s/%s" % (ctx.attr.repository, ctx.label.package)
def reverse(lst):
result = []
@@ -400,6 +405,7 @@ docker_build_ = rule(
"tars": attr.label_list(allow_files=tar_filetype),
"debs": attr.label_list(allow_files=deb_filetype),
"files": attr.label_list(allow_files=True),
+ "legacy_repository_naming": attr.bool(default=False),
"mode": attr.string(default="0555"),
"symlinks": attr.string_dict(),
"entrypoint": attr.string_list(),