github.com/extrame/fabric-ca@v2.0.0-alpha+incompatible/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 8 usage() { 9 echo "Usage: $0 <username> <password>" 10 echo "<username> and <password> credentials for the repository" 11 echo "ENV:" 12 echo " NS=$NS" 13 echo " VERSION=$VERSION" 14 echo " TWO_DIGIT_VERSION=$TWO_DIGIT_VERSION" 15 exit 1 16 } 17 18 missing() { 19 echo "Error: some image(s) missing from registry" 20 echo "ENV:" 21 echo " NS=$NS" 22 echo " VERSION=$VERSION" 23 echo " TWO_DIGIT_VERSION=$TWO_DIGIT_VERSION" 24 exit 1 25 } 26 27 failed() { 28 echo "Error: multiarch manifest push failed" 29 echo "ENV:" 30 echo " NS=$NS" 31 echo " VERSION=$VERSION" 32 echo " TWO_DIGIT_VERSION=$TWO_DIGIT_VERSION" 33 exit 1 34 } 35 36 USER=${1:-nobody} 37 PASSWORD=${2:-nohow} 38 NS=${NS:-hyperledger} 39 VERSION=${BASE_VERSION:-1.3.0} 40 TWO_DIGIT_VERSION=${TWO_DIGIT_VERSION:-1.3} 41 42 if [ "$#" -ne 2 ]; then 43 usage 44 fi 45 46 # verify that manifest-tool is installed and found on PATH 47 which manifest-tool 48 if [ "$?" -ne 0 ]; then 49 echo "manifest-tool not installed or not found on PATH" 50 exit 1 51 fi 52 53 IMAGES="fabric-ca" 54 55 # check that all images have been published 56 for image in ${IMAGES}; do 57 docker pull ${NS}/${image}:amd64-${VERSION} || missing 58 docker pull ${NS}/${image}:s390x-${VERSION} || missing 59 done 60 61 # push the multiarch manifest and tag with just $VERSION and 'latest' 62 for image in ${IMAGES}; do 63 manifest-tool --username ${USER} --password ${PASSWORD} push from-args\ 64 --platforms linux/amd64,linux/s390x --template "${NS}/${image}:ARCH-${VERSION}"\ 65 --target "${NS}/${image}:${VERSION}" 66 # manifest-tool --username ${USER} --password ${PASSWORD} push from-args\ 67 # --platforms linux/amd64,linux/s390x --template "${NS}/${image}:ARCH-${VERSION}"\ 68 # --target "${NS}/${image}:latest" 69 manifest-tool --username ${USER} --password ${PASSWORD} push from-args\ 70 --platforms linux/amd64,linux/s390x --template "${NS}/${image}:ARCH-${VERSION}"\ 71 --target "${NS}/${image}:${TWO_DIGIT_VERSION}" 72 done 73 74 # test that manifest is working as expected 75 for image in ${IMAGES}; do 76 docker pull ${NS}/${image}:${VERSION} || failed 77 docker pull ${NS}/${image}:${TWO_DIGIT_VERSION} || failed 78 # docker pull ${NS}/${image}:latest || failed 79 done 80 81 echo "Successfully pushed multiarch manifest" 82 exit 0