diff options
author | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2020-10-23 11:35:44 +0200 |
---|---|---|
committer | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2020-10-26 10:28:11 +0000 |
commit | 54286a345710b0b73e1b58e8c2fa4caa54bed48e (patch) | |
tree | 9925697bb326c81ef855246a07b218314e38d829 | |
parent | 579bdb2178700a6c7e684066d6526292a32cf130 (diff) |
Use temporary Docker client config
Change-Id: I2c864cbd553e377aa594badf4df58206e40e5794
Issue-ID: OOM-2605
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
-rwxr-xr-x | build/build_nexus_blob.sh | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/build/build_nexus_blob.sh b/build/build_nexus_blob.sh index 004528d8..9c4b5e69 100755 --- a/build/build_nexus_blob.sh +++ b/build/build_nexus_blob.sh @@ -156,10 +156,8 @@ push_pip () { } docker_login () { - 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 + echo "Docker login to ${DOCKER_REGISTRY}" + echo -n "${NEXUS_PASSWORD}" | docker --config "${DOCKER_CONFIG_DIR}" login -u "${NEXUS_USERNAME}" --password-stdin ${DOCKER_REGISTRY} > /dev/null } push_docker () { @@ -181,7 +179,7 @@ push_docker () { PUSH="$(sed -e 's/'"${repo_host}"'/'"${DOCKER_REGISTRY}"'/' <<< ${IMAGE})" fi docker tag ${IMAGE} ${PUSH} - docker push ${PUSH} + docker --config "${DOCKER_CONFIG_DIR}" push ${PUSH} # Remove created tag docker rmi ${PUSH} echo "${IMAGE} pushed as ${PUSH} to Nexus" @@ -279,11 +277,8 @@ if [ ${#NXS_DOCKER_IMG_LISTS[@]} -eq 0 ]; then NXS_DOCKER_IMG_LISTS=("${NXS_DOCKER_IMG_LIST}" "${NXS_RKE_DOCKER_IMG_LIST}" "${NXS_K8S_DOCKER_IMG_LIST}") fi -# Backup the current docker registry settings -if [ -f ~/.docker/config.json ]; then - DOCKER_CONF_BACKUP="$(eval ${TIMESTAMP}_config.json.bk)" - mv ~/.docker/config.json ~/.docker/${DOCKER_CONF_BACKUP} -fi +# Create Docker client config dir +DOCKER_CONFIG_DIR=$(mktemp -p /tmp -d .docker.XXXXXXXX) # Setup default ports published to host as docker registry PUBLISHED_PORTS="-p ${NEXUS_PORT}:${NEXUS_EXPOSED_PORT} -p ${NEXUS_DOCKER_PORT}:${NEXUS_DOCKER_EXPOSED_PORT}" @@ -425,14 +420,13 @@ done # Stop the Nexus and cleanup # ############################## -echo "Stopping Nexus and returning backups" +echo "Stopping Nexus" # Stop the Nexus docker stop ${NEXUS_CONT_ID} > /dev/null -if [ -f ~/.docker/${DOCKER_CONF_BACKUP} ]; then - mv -f ~/.docker/${DOCKER_CONF_BACKUP} ~/.docker/config.json -fi +# Drop temporary Docker client config dir +rm -rf ${DOCKER_CONFIG_DIR} echo "Nexus blob is built" exit 0 |