github.com/sykesm/fabric@v1.1.0-preview.0.20200129034918-2aa12b1a0181/scripts/multiarch.sh (about) 1 #!/bin/sh 2 # 3 # Copyright IBM Corp. All Rights Reserved. 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 # This script publishes the fabric docker images to hyperledger dockerhub and nexus3 repositories. 8 # when publishing the images to dockerhub the values for NS_PULL & NS_PUSH variables set to default values. 9 # when publishing the images to nexus3 repository the values for NS_PULL & NS_PUSH variables set like below 10 # NS_PULL=nexus3.hyperledger.org:10001/hyperledger & NS_PUSH=nexus3.hyperledger.org:10002/hyperledger 11 # since nexus has separate port numbers to pull and push the images to nexus3. 12 13 usage() { 14 echo "Usage: $0 <username> <password>" 15 echo "<username> and <password> credentials for the repository" 16 echo "ENV:" 17 echo " NS_PULL=$NS_PULL" 18 echo " NS_PUSH=$NS_PUSH" 19 echo " VERSION=$VERSION" 20 echo " TWO_DIGIT_VERSION=$TWO_DIGIT_VERSION" 21 exit 1 22 } 23 24 missing() { 25 echo "Error: some image(s) missing from registry" 26 echo "ENV:" 27 echo " NS_PULL=$NS_PULL" 28 echo " NS_PUSH=$NS_PUSH" 29 echo " VERSION=$VERSION" 30 echo " TWO_DIGIT_VERSION=$TWO_DIGIT_VERSION" 31 exit 1 32 } 33 34 failed() { 35 echo "Error: multiarch manifest push failed" 36 echo "ENV:" 37 echo " NS_PULL=$NS_PULL" 38 echo " NS_PUSH=$NS_PUSH" 39 echo " VERSION=$VERSION" 40 echo " TWO_DIGIT_VERSION=$TWO_DIGIT_VERSION" 41 exit 1 42 } 43 44 USER=${1:-nobody} 45 PASSWORD=${2:-nohow} 46 NS_PULL=${NS_PULL:-hyperledger} 47 NS_PUSH=${NS_PUSH:-hyperledger} 48 VERSION=${BASE_VERSION:-1.3.0} 49 TWO_DIGIT_VERSION=${TWO_DIGIT_VERSION:-1.3} 50 51 if [ "$#" -ne 2 ]; then 52 usage 53 fi 54 55 # verify that manifest-tool is installed and found on PATH 56 if ! [ -x "$(command -v manifest-tool)" ]; then 57 echo "manifest-tool not installed or not found on PATH" 58 exit 1 59 fi 60 61 IMAGES="fabric-baseos fabric-peer fabric-orderer fabric-ccenv fabric-tools" 62 63 # check that all images have been published 64 for image in ${IMAGES}; do 65 docker pull "${NS_PULL}/${image}:amd64-${VERSION}" || missing 66 done 67 68 # push the multiarch manifest and tag with just $VERSION 69 for image in ${IMAGES}; do 70 manifest-tool --username "${USER}" --password "${PASSWORD}" push from-args \ 71 --platforms linux/amd64 --template "${NS_PULL}/${image}:ARCH-${VERSION}" \ 72 --target "${NS_PUSH}/${image}:${VERSION}" 73 manifest-tool --username "${USER}" --password "${PASSWORD}" push from-args \ 74 --platforms linux/amd64 --template "${NS_PULL}/${image}:ARCH-${VERSION}" \ 75 --target "${NS_PUSH}/${image}:${TWO_DIGIT_VERSION}" 76 done 77 78 # test that manifest is working as expected 79 for image in ${IMAGES}; do 80 docker pull "${NS_PULL}/${image}:${VERSION}" || failed 81 docker pull "${NS_PULL}/${image}:${TWO_DIGIT_VERSION}" || failed 82 done 83 84 echo "Successfully pushed multiarch manifest" 85 exit 0