Skip to content

Commit e01cf5b

Browse files
FAB-10294 script to publish multiarch manifest
Change-Id: I5fd2ebb60be5b62d34bd24b6b73e4299ccf376f3 Signed-off-by: Christopher Ferris <chrisfer@us.ibm.com>
1 parent bfb4b0f commit e01cf5b

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

scripts/multiarch.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
exit 1
15+
}
16+
17+
missing() {
18+
echo "Error: some image(s) missing from registry"
19+
echo "ENV:"
20+
echo " NS=$NS"
21+
echo " VERSION=$VERSION"
22+
exit 1
23+
}
24+
25+
failed() {
26+
echo "Error: multiarch manifest push failed"
27+
echo "ENV:"
28+
echo " NS=$NS"
29+
echo " VERSION=$VERSION"
30+
exit 1
31+
}
32+
33+
USER=${1:-nobody}
34+
PASSWORD=${2:-nohow}
35+
NS=${NS:-hyperledger}
36+
VERSION=${BASE_VERSION:-1.1.0}
37+
38+
if [ "$#" -ne 2 ]; then
39+
usage
40+
fi
41+
42+
# verify that manifest-tool is installed and found on PATH
43+
which manifest-tool
44+
if [ "$?" -ne 0 ]; then
45+
echo "manifest-tool not installed or not found on PATH"
46+
exit 1
47+
fi
48+
49+
IMAGES="fabric-peer fabric-orderer fabric-ccenv fabric-tools"
50+
51+
# check that all images have been published
52+
for image in ${IMAGES}; do
53+
docker pull ${NS}/${image}:amd64-${VERSION} || missing
54+
docker pull ${NS}/${image}:s390x-${VERSION} || missing
55+
done
56+
57+
# push the multiarch manifest and tag with just $VERSION and 'latest'
58+
for image in ${IMAGES}; do
59+
manifest-tool --username ${USER} --password ${PASSWORD} push from-args\
60+
--platforms linux/amd64,linux/s390x --template "${NS}/${image}:ARCH-${VERSION}"\
61+
--target "${NS}/${image}:${VERSION}"
62+
manifest-tool --username ${USER} --password ${PASSWORD} push from-args\
63+
--platforms linux/amd64,linux/s390x --template "${NS}/${image}:ARCH-${VERSION}"\
64+
--target "${NS}/${image}:latest"
65+
done
66+
67+
# test that manifest is working as expected
68+
for image in ${IMAGES}; do
69+
docker pull ${NS}/${image}:${VERSION} || failed
70+
docker pull ${NS}/${image}:latest || failed
71+
done
72+
73+
echo "Successfully pushed multiarch manifest"
74+
exit 0

0 commit comments

Comments
 (0)