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,