diff --git a/docker-hooks.sh b/docker-hooks.sh new file mode 100644 index 0000000..3d363d4 --- /dev/null +++ b/docker-hooks.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +CLR_URL="https://cdn.download.clearlinux.org/releases" + +# Return tag value or NULL if not found +function get_tag { + pkg=$1 + + clr_ver=`docker run --rm clearlinux/os-core cat /usr/lib/os-release | grep VERSION_ID` + clr_ver=${clr_ver##*=} + src_url="$CLR_URL/$clr_ver/clear/source/package-sources" + matches=$(curl $src_url 2>/dev/null | grep $pkg) + + # no matches, return NULL tag + if [ -z "$matches" ]; then + echo "" + echo "no $pkg found on the release $clr_ver" + exit 0 + fi + + matches=($matches) + for((j=0;j<${#matches[@]};j++)) + do + if [ ${matches[j]} == $pkg ]; then + ver=${matches[j+1]} + fi + done + + echo "$ver" +} + +function get_tags_in_docker { + img=$1 + + tag_url="https://registry.hub.docker.com/v2/repositories/$img/tags/" + tags=$(curl $tag_url 2>/dev/null | docker run -i stedolan/jq '."results"[]["name"]') + echo $tags +} diff --git a/redis/hooks/post_push b/redis/hooks/post_push new file mode 100755 index 0000000..6e28a3d --- /dev/null +++ b/redis/hooks/post_push @@ -0,0 +1,19 @@ +#!/bin/bash +echo "=> Tagging the image" + +set -e + +. ../docker-hooks.sh + +image="clearlinux/redis" +tag=$(get_tag redis-native) + +if [ -z "$tag" ]; then + echo "no $pkg found on the release $clr_ver" +else + docker tag $image:latest $image:$tag + docker push $image:$tag + major_tag=${tag%%.*} + docker tag $image:latest $image:$major_tag + docker push $image:$major_tag +fi