Skip to content

Commit

Permalink
Add Tag info to docker label meta data
Browse files Browse the repository at this point in the history
Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
  • Loading branch information
jipanyang committed Sep 18, 2018
1 parent ef4ee9f commit 874b4d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ sonic_get_version() {
local latest_tag=$(git describe --tags --abbrev=0)
local branch_name=$(git rev-parse --abbrev-ref HEAD)
if [ -n "$(git status --untracked-files=no -s --ignore-submodules)" ]; then
local dirty="-dirty-$DIRTY_SUFFIX"
if [ -z "$DIRTY_SUFFIX" ]; then
local dirty="-dirty-"$(date +%Y%m%d\.%H%M%S)
else
local dirty="-dirty-$DIRTY_SUFFIX"
fi
fi
BUILD_NUMBER=${BUILD_NUMBER:-0}
## Check if we are on tagged commit
Expand Down
3 changes: 3 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down Expand 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
Expand Down

0 comments on commit 874b4d9

Please sign in to comment.