Labels in docker_build rule

92 views
Skip to first unread message

Yugui

unread,
Nov 2, 2015, 3:19:01 AM11/2/15
to bazel-...@googlegroups.com
I am looking for a way to embed source git revision to metadata of docker images built by "docker_build" rule.
This is necessary for compatibility to our deployment system.

Before trying Bazel, I have been using a custom docker image builder which embeds the information as a label.  Is there any way to do something similar with Bazel?

Regards,

Brian Silverman

unread,
Nov 2, 2015, 11:18:06 AM11/2/15
to Yugui, bazel-discuss
The preferred way to get the git revision is using a --workspace_status_command, like tools/buildstamp/get_workspace_status. There might be a more direct way, but you could get the information into a Skylark rule by calling a HOST cc_binary which depends on a cc_library with something in the linkstamp attribute.

One thing to note is the git revision changing won't cause the rules to be rebuilt. Instead, whenever the rules are rebuilt because any other dependencies changes, the current git revision will be retrieved and used.

I don't know how to get the information from the workspace status files into the docker rules.

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

Yugui

unread,
Nov 3, 2015, 8:43:39 PM11/3/15
to Brian Silverman, bazel-discuss
On Tue, Nov 3, 2015 at 1:18 AM Brian Silverman <bsilve...@gmail.com> wrote:
The preferred way to get the git revision is using a --workspace_status_command, like tools/buildstamp/get_workspace_status. There might be a more direct way, but you could get the information into a Skylark rule by calling a HOST cc_binary which depends on a cc_library with something in the linkstamp attribute.

One thing to note is the git revision changing won't cause the rules to be rebuilt. Instead, whenever the rules are rebuilt because any other dependencies changes, the current git revision will be retrieved and used.

Thank you, Brian.  That's very helpful.
 
I don't know how to get the information from the workspace status files into the docker rules.

For now, docker_build rule looks to lack any way to add such arbitrary metadata to docker images.  But if it had, I could combine it with linkstamp. I'll try asking about this enhancement of docker_build in bazel-dev.
Reply all
Reply to author
Forward
0 new messages