Proposal: Docker LABEL support in docker_build

32 views
Skip to first unread message

Yugui

unread,
Nov 3, 2015, 10:30:59 PM11/3/15
to baze...@googlegroups.com
I am wondering if docker_build rule can support LABELs. What do you think?

Background
I am looking for a way to attach some metadata, e.g. source git revision, to docker image.
This is necessary for compatibility to our deployment system.

I got a suggestion to use --workspace_status_command in a thread in bazel-discuss, but I still need a way to associate the status to docker images.
If there were such a way, I could write a skylark rule which combines --workspace_status_command with it.

Proposal
I propose adding a new attribute "labels" to docker_build rule.
The attribute keeps a mapping from label names to their corresponding values.

The values in the mapping are represented as paths to files which contain actual values but not immediate values.
This is necessary to automatically generate such values with HOST binary as far as it is deterministic.

e.g.
docker_build(
    name = "my-image",
    files = [ ... ],
    labels = {
        "com.example.my-label": "dir/subdir/label-value.out",
    },
)

Another possible design would be to simply read a mapping from a file.
docker_build(
    name = "my-image",
    files = [ ... ],
    label = "dir/subdir/label-mapping.json",
)

It might be easier for users to maintain if they have only manually-configured label values.
But I am worrying about that it gives too much flexibility to HOST binaries when label values are automatically generated.

Regards,

Damien Martin-guillerez

unread,
Nov 9, 2015, 7:48:43 AM11/9/15
to Yugui, baze...@googlegroups.com, matt...@google.com
+Matthew Moore from GCE

Hello I would be happy to review such a change. I prefer slightly the first version.

--
You received this message because you are subscribed to the Google Groups "bazel-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-dev+...@googlegroups.com.
To post to this group, send email to baze...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-dev/CAB%3Drkjy3YL8ogVJKYceC3SSOsbJ_VYPM-wLOjGunXqbK8mZ-JQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Moore

unread,
Nov 9, 2015, 12:02:12 PM11/9/15
to Damien Martin-guillerez, Yugui, baze...@googlegroups.com, Scott Zawalski
I think it would be more consistent to have the literal value for the first iteration (which is all any of the metadata attributes support).  This should be quite straightforward.

This does open the (good) general question of how we might inject file contents as values for any of the metadata attributes.


Is there a good precedent for this in Bazel, that we can follow?
-M
--
Matthew Moore
DI/Docker (aka Convoy)
Developer Infrastructure @ Google

Damien Martin-guillerez

unread,
Nov 10, 2015, 8:02:31 AM11/10/15
to Matthew Moore, Yugui, baze...@googlegroups.com, Scott Zawalski
There is no good precedent that I can think off. I did use two different optional attribute for the pkg_deb rule last month and add an extra check for collision.

Yugui

unread,
Nov 21, 2015, 5:04:05 AM11/21/15
to Damien Martin-guillerez, baze...@googlegroups.com, matt...@google.com
On Mon, Nov 9, 2015 at 9:48 PM Damien Martin-guillerez <dmar...@google.com> wrote:
+Matthew Moore from GCE

Hello I would be happy to review such a change. I prefer slightly the first version.

Thank you.
I have prototyped the new attribute to docker_build rule. But I am not confident if this way of implementation is correct.  Let me ask some questions in the following URL.
Reply all
Reply to author
Forward
0 new messages