Fix mirror script logging in to registry.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Stanislav Nikitin 2022-06-27 02:00:19 +05:00
parent 7173cab2ba
commit 49ece50d05
Signed by: pztrn
GPG Key ID: 1E944A0F0568B550

View File

@ -3,7 +3,8 @@
# The Docker Image Mirror script. # The Docker Image Mirror script.
WHAT_TO_MIRROR=() WHAT_TO_MIRROR=()
DESTINATION_REGISTRY=code.pztrn.name/containers/mirror DESTINATION_REGISTRY=code.pztrn.name
DESTINATION_PROJECT=${DESTINATION_REGISTRY}/containers/mirror
USER=${REGISTRY_USER} USER=${REGISTRY_USER}
PASSWORD=${REGISTRY_PASSWORD} PASSWORD=${REGISTRY_PASSWORD}
@ -30,15 +31,15 @@ function mirror() {
# shellcheck disable=SC1083 # shellcheck disable=SC1083
image_hash=$(docker images -a | grep "^${image_name}" | grep "${image_version}" | awk {' print $3 '}) image_hash=$(docker images -a | grep "^${image_name}" | grep "${image_version}" | awk {' print $3 '})
echo -n "${image_hash} received, retag as '${DESTINATION_REGISTRY}/${image}'... " echo -n "${image_hash} received, retag as '${DESTINATION_PROJECT}/${image}'... "
if ! docker tag "${image_hash}" "${DESTINATION_REGISTRY}/${image}" &>/dev/null; then if ! docker tag "${image_hash}" "${DESTINATION_PROJECT}/${image}" &>/dev/null; then
echo "TAGGING FAILED" echo "TAGGING FAILED"
exit 1 exit 1
fi fi
echo -n "pushing... " echo -n "pushing... "
if ! docker push "${DESTINATION_REGISTRY}/${image}" &>/dev/null; then if ! docker push "${DESTINATION_PROJECT}/${image}" &>/dev/null; then
echo "FAILED" echo "FAILED"
exit 1 exit 1
fi fi
@ -46,7 +47,7 @@ function mirror() {
echo "OK" echo "OK"
docker image rm "${image}" &>/dev/null docker image rm "${image}" &>/dev/null
docker image rm "${DESTINATION_REGISTRY}/${image}" &>/dev/null docker image rm "${DESTINATION_PROJECT}/${image}" &>/dev/null
} }
# Login to registry. # Login to registry.