Skip to content

Commit

Permalink
add tag removal from dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed May 4, 2018
1 parent b520b8d commit 279fee2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,53 @@ fi

dbtags=( mysql rethinkdb )

# Read dockerhub login/password from a separate file
source .dockerhub

# Obtain dockerhub API auth token
jstoken=`curl -sX POST -H "Content-Type: application/json" -d "{\"username\":\"${user}\",\"password\":\"${pass}\"}" \
https://hub.docker.com/v2/users/login/ | python -c "import json,sys;obj=json.load(sys.stdin);print obj['token'];"`

# Remove earlier builds
for dbtag in "${dbtags[@]}"
do
if [ FULLRELEASE = 1 ]; then
docker rmi -f tinode/tinode-${dbtag}:latest
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT ${jstoken}" \
https://hub.docker.com/v2/repositories/tinode/tinode-${dbtag}/tags/latest/

docker rmi -f tinode/tinode-${dbtag}:"${ver[0]}.${ver[1]}"
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT ${jstoken}" \
https://hub.docker.com/v2/repositories/tinode/tinode-${dbtag}/tags/${ver[0]}.${ver[1]}/
fi
docker rmi -f tinode/tinode-${dbtag}:"${ver[0]}.${ver[1]}.${ver[2]}"
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT ${jstoken}" \
https://hub.docker.com/v2/repositories/tinode/tinode-${dbtag}/tags/${ver[0]}.${ver[1]}.${ver[2]}/
done

if [ FULLRELEASE = 1 ]; then
docker rmi tinode/chatbot:latest
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT ${jstoken}" \
https://hub.docker.com/v2/repositories/tinode/chatbot/tags/latest/
docker rmi tinode/chatbot:"${ver[0]}.${ver[1]}"
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT ${jstoken}" \
https://hub.docker.com/v2/repositories/tinode/chatbot/tags/${ver[0]}.${ver[1]}/
fi
docker rmi tinode/chatbot:"${ver[0]}.${ver[1]}.${ver[2]}"
curl -i -X DELETE \
-H "Accept: application/json" \
-H "Authorization: JWT ${jstoken}" \
https://hub.docker.com/v2/repositories/tinode/chatbot/tags/${ver[0]}.${ver[1]}.${ver[2]}/

# Build an images for various DB backends
for dbtag in "${dbtags[@]}"
Expand Down

0 comments on commit 279fee2

Please sign in to comment.