From 0e85986088a97135dc4472d49c1f2fa8bc264318 Mon Sep 17 00:00:00 2001 From: Jipan Yang Date: Fri, 21 Sep 2018 10:44:28 -0700 Subject: [PATCH] Add Tag info to docker label meta data (#2058) * Add Tag info to docker label meta data Signed-off-by: Jipan Yang * Move DIRTY_SUFFIX to sonic_get_version() Signed-off-by: Jipan Yang --- functions.sh | 1 + slave.mk | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/functions.sh b/functions.sh index 01f645ca72..3605877834 100644 --- a/functions.sh +++ b/functions.sh @@ -51,6 +51,7 @@ docker_try_rmi() { } sonic_get_version() { + DIRTY_SUFFIX="$(date +%Y%m%d\.%H%M%S)" local describe=$(git describe --tags) local latest_tag=$(git describe --tags --abbrev=0) local branch_name=$(git rev-parse --abbrev-ref HEAD) diff --git a/slave.mk b/slave.mk index c0e2272671..bb1d86be48 100644 --- a/slave.mk +++ b/slave.mk @@ -9,6 +9,7 @@ SHELL = /bin/bash USER = $(shell id -un) UID = $(shell id -u) GUID = $(shell id -g) +SONIC_GET_VERSION=$(shell . functions.sh && sonic_get_version) .SECONDEXPANSION: @@ -393,6 +394,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_SIMPLE_DOCKER_IMAGES)) : $(TARGET_PATH)/%.g --build-arg uid=$(UID) \ --build-arg guid=$(GUID) \ --build-arg docker_container_name=$($*.gz_CONTAINER_NAME) \ + --label Tag=$(SONIC_GET_VERSION) \ -t $* $($*.gz_PATH) $(LOG) docker save $* | gzip -c > $@ # Clean up @@ -425,6 +427,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_DOCKER_IMAGES)) : $(TARGET_PATH)/%.gz : .pl --build-arg uid=$(UID) \ --build-arg guid=$(GUID) \ --build-arg docker_container_name=$($*.gz_CONTAINER_NAME) \ + --label Tag=$(SONIC_GET_VERSION) \ -t $* $($*.gz_PATH) $(LOG) docker save $* | gzip -c > $@ # Clean up @@ -514,9 +517,6 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ chmod +x sonic_debian_extension.sh, ) - DIRTY_SUFFIX="$(shell date +%Y%m%d\.%H%M%S)" - export DIRTY_SUFFIX - USERNAME="$(USERNAME)" \ PASSWORD="$(PASSWORD)" \ ./build_debian.sh $(LOG)