aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShyam Sunder2019-09-28 16:49:01 -0400
committerShyam Sunder2019-09-28 19:28:17 -0400
commit2af304b84441ad090ffc20568384e2426dbdb148 (patch)
tree6268cd7933b60668dcc3e26bcf815f6224f2a1a1
parent0c05330cfc634a37938ffe28e7c60da2a7935952 (diff)
docker: add hooks to autotag images
-rwxr-xr-xclient/hooks/build2
-rwxr-xr-xclient/hooks/post_push19
-rwxr-xr-xserver/hooks/post_push19
3 files changed, 39 insertions, 1 deletions
diff --git a/client/hooks/build b/client/hooks/build
index 8434e52..86d0c78 100755
--- a/client/hooks/build
+++ b/client/hooks/build
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
BUILD_INFO=docker-$(echo $SOURCE_COMMIT | cut -c1-7)-auto
echo "Using BUILD_INFO=$BUILD_INFO"
docker build --build-arg BUILD_INFO=$BUILD_INFO -f $DOCKERFILE_PATH -t $IMAGE_NAME .
diff --git a/client/hooks/post_push b/client/hooks/post_push
new file mode 100755
index 0000000..74c19dd
--- /dev/null
+++ b/client/hooks/post_push
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+add_tag() {
+ echo "Also tagging image as ${DOCKER_REPO}:${1}"
+ docker tag $IMAGE_NAME $DOCKER_REPO:$1
+ docker push $DOCKER_REPO:$1
+}
+
+CLOSEST_VER=$(git describe --tags --abbrev=0)
+CLOSEST_MAJOR_VER=$(echo ${CLOSEST_VER} | cut -d'.' -f1)
+CLOSEST_MINOR_VER=$(echo ${CLOSEST_VER} | cut -d'.' -f2)
+
+add_tag "${CLOSEST_MAJOR_VER}-edge"
+add_tag "${CLOSEST_MAJOR_VER}.${CLOSEST_MINOR_VER}-edge"
+
+if git describe --exact-match --abbrev=0 2> /dev/null; then
+ add_tag "${CLOSEST_MAJOR_VER}"
+ add_tag "${CLOSEST_MAJOR_VER}.${CLOSEST_MINOR_VER}"
+fi \ No newline at end of file
diff --git a/server/hooks/post_push b/server/hooks/post_push
new file mode 100755
index 0000000..74c19dd
--- /dev/null
+++ b/server/hooks/post_push
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+add_tag() {
+ echo "Also tagging image as ${DOCKER_REPO}:${1}"
+ docker tag $IMAGE_NAME $DOCKER_REPO:$1
+ docker push $DOCKER_REPO:$1
+}
+
+CLOSEST_VER=$(git describe --tags --abbrev=0)
+CLOSEST_MAJOR_VER=$(echo ${CLOSEST_VER} | cut -d'.' -f1)
+CLOSEST_MINOR_VER=$(echo ${CLOSEST_VER} | cut -d'.' -f2)
+
+add_tag "${CLOSEST_MAJOR_VER}-edge"
+add_tag "${CLOSEST_MAJOR_VER}.${CLOSEST_MINOR_VER}-edge"
+
+if git describe --exact-match --abbrev=0 2> /dev/null; then
+ add_tag "${CLOSEST_MAJOR_VER}"
+ add_tag "${CLOSEST_MAJOR_VER}.${CLOSEST_MINOR_VER}"
+fi \ No newline at end of file

© 2015 - 2026 Jakob L. Kreuze