Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git commit hash in dockerfile as label

How to add git commit hash or any other dynamically inferred value in Dockerfile.

LABEL vcs-ref=$(git rev-parse --short HEAD)

Something like this?

like image 537
Rajesh Rajendran Avatar asked Aug 09 '18 15:08

Rajesh Rajendran


1 Answers

I found it atlast,

use docker build --build-arg vcs-ref=$(git rev-parse --short HEAD)

while building.

But have to initialize the variable in vcs-ref in Dockerfile

ARG vcs-ref=0
ENV vcs-ref=$vcs-ref
like image 80
Rajesh Rajendran Avatar answered Sep 20 '22 19:09

Rajesh Rajendran