summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-10-22 11:40:20 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-10-26 10:27:18 +0000
commit15d5ffb98130044599995c4a40f10e6153290b0d (patch)
treea94d08136973e412086449bfb11db9aa32975211 /build
parent8583bf98b526c23d487f0159401a65400fb044fa (diff)
Push all images to simulated Docker registry only
In previous implementation all images were pushed to their original registries which were simulated locally. This change retags all images to locally simulated docker registry only and pushes them there accordingly. Created temporary tag is dropped at the end for order. Change-Id: If1b6633fdcc13d47c6e2b26792980320dce7f49a Issue-ID: OOM-2605 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'build')
-rwxr-xr-xbuild/build_nexus_blob.sh30
1 files changed, 15 insertions, 15 deletions
diff --git a/build/build_nexus_blob.sh b/build/build_nexus_blob.sh
index b41d6cab..fe69181d 100755
--- a/build/build_nexus_blob.sh
+++ b/build/build_nexus_blob.sh
@@ -175,12 +175,10 @@ push_pip () {
}
docker_login () {
- for REGISTRY in $(sed -n '/\.[^/].*\//p' ${1} | sed -e 's/\/.*$//' | sort -u | grep -v ${DEFAULT_REGISTRY}) ${DOCKER_REGISTRY}; do
- if ! grep -wqs ${REGISTRY} ~/.docker/config.json; then
- echo "Docker login to ${REGISTRY}"
- echo -n "${NEXUS_PASSWORD}" | docker login -u "${NEXUS_USERNAME}" --password-stdin ${REGISTRY} > /dev/null
- fi
- done
+ if ! grep -wqs ${DOCKER_REGISTRY} ~/.docker/config.json; then
+ echo "Docker login to ${DOCKER_REGISTRY}"
+ echo -n "${NEXUS_PASSWORD}" | docker login -u "${NEXUS_USERNAME}" --password-stdin ${DOCKER_REGISTRY} > /dev/null
+ fi
}
push_docker () {
@@ -196,13 +194,15 @@ push_docker () {
fi
elif [[ -z $(sed -n '/\.[^/].*\//p' <<< ${IMAGE}) ]]; then
PUSH="${DOCKER_REGISTRY}/${IMAGE}"
- fi
- if [[ ! -z ${PUSH} ]]; then
- docker tag ${IMAGE} ${PUSH}
else
- PUSH="${IMAGE}"
+ # substitute all host names with $DOCKER_REGISTRY
+ repo_host=$(sed -e 's/\/.*$//' <<< ${IMAGE})
+ PUSH="$(sed -e 's/'"${repo_host}"'/'"${DOCKER_REGISTRY}"'/' <<< ${IMAGE})"
fi
- docker push ${PUSH}
+ docker tag ${IMAGE} ${PUSH}
+ docker push ${PUSH}
+ # Remove created tag
+ docker rmi ${PUSH}
echo "${IMAGE} pushed as ${PUSH} to Nexus"
done
}
@@ -436,12 +436,12 @@ fi
## Populate Docker repository #
###############################
-# Login to simulated docker registries
+# Login to docker registry simulated by Nexus container
# Push images to private nexus based on the lists
-# Images from default registry need to be tagged to private registry
-# and those without defined repository in tag uses default repository 'library'
+# All images need to be tagged to simulated registry
+# and those without defined repository in tag use default repository 'library'
+docker_login
for DOCKER_IMG_LIST in "${NXS_DOCKER_IMG_LISTS[@]}"; do
- docker_login "${DOCKER_IMG_LIST}"
push_docker "${DOCKER_IMG_LIST}"
done