mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-6428 Add script to handle tagging with the image digest.
This commit is contained in:
31
scripts/pushDockerDigestTag.sh
Normal file
31
scripts/pushDockerDigestTag.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
scriptName=`basename "$0"`
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: ${scriptName} <imageName> <existingTag>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "${scriptName} called with:"
|
||||
image=$1
|
||||
echo " image: $image"
|
||||
existingTag=$2
|
||||
echo " existingTag: $existingTag"
|
||||
|
||||
DIGEST_LENGTH=12
|
||||
|
||||
# Note that this command should work even if the image is already present locally.
|
||||
digest=`docker pull ${image}:${existingTag} | grep "Digest:" | awk -F':' '{print $3}' | cut -c 1-$DIGEST_LENGTH`
|
||||
|
||||
if [ ${#digest} != $DIGEST_LENGTH ]
|
||||
then
|
||||
echo "Unexpected length for digest: '$digest'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
newTag=${existingTag}_${digest}
|
||||
docker tag ${image}:${existingTag} ${image}:${newTag}
|
||||
docker push ${image}:${newTag}
|
||||
|
||||
echo "Pushed ${image}:${existingTag} to ${image}:${newTag}"
|
Reference in New Issue
Block a user