This repository has been archived by the owner on May 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
build-multiarch.sh
executable file
·103 lines (79 loc) · 2.58 KB
/
build-multiarch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
source ./build-common.sh
function buildManifest() {
IMAGE_NAME="nessusio/$1"
IMAGE_TAG="$2"
echo "docker manifest rm ${IMAGE_NAME}:${IMAGE_TAG}"
docker manifest rm "${IMAGE_NAME}:${IMAGE_TAG}"
echo "docker manifest create ${IMAGE_NAME}:${IMAGE_TAG}"
docker manifest create "${IMAGE_NAME}:${IMAGE_TAG}" \
--amend "${IMAGE_NAME}:${IMAGE_TAG}-amd64" \
--amend "${IMAGE_NAME}:${IMAGE_TAG}-arm64"
echo "docker manifest annotate ${IMAGE_NAME}:${IMAGE_TAG}"
docker manifest annotate "${IMAGE_NAME}:${IMAGE_TAG}" \
"${IMAGE_NAME}:${IMAGE_TAG}-arm64" \
--os=linux --arch=arm64 --variant=v8
echo "docker manifest inspect ${IMAGE_NAME}:${IMAGE_TAG}"
docker manifest inspect "${IMAGE_NAME}:${IMAGE_TAG}"
if [[ $? != 0 ]]; then
echo "[Error] No such manifest: ${IMAGE_NAME}:${IMAGE_TAG}"
exit 1
fi
if [[ $push == true ]]; then
echo "docker manifest push ${IMAGE_NAME}:${IMAGE_TAG}"
docker manifest push "${IMAGE_NAME}:${IMAGE_TAG}"
fi
}
function buildImage () {
shortName=$1
if [[ $shortName == "cardano-node" || $shortName == "cardano-tools" ]]; then
VERSION_MAJOR=${CARDANO_VER}
VERSION_REV=${CARDANO_REV}
elif [[ $shortName == "mmonit" ]]; then
VERSION_MAJOR=${MMONIT_VER}
VERSION_REV=${MMONIT_REV}
elif [[ $shortName == "monit" ]]; then
VERSION_MAJOR=${MONIT_VER}
VERSION_REV=${MONIT_REV}
else
echo "[Error] Illegal argument: $1"
echo "Usage: $0 [all|cardano-node|cardano-tools|mmonit|monit] [push]"
exit 1
fi
if [[ "${VERSION_REV}" == "" ]]; then
FULL_VERSION="${VERSION_MAJOR}"
LATEST_VERSION="latest"
elif [[ "${VERSION_REV}" == "-dev" ]]; then
FULL_VERSION="${VERSION_MAJOR}-dev"
LATEST_VERSION="dev"
else
FULL_VERSION="${VERSION_MAJOR}${VERSION_REV}"
LATEST_VERSION="latest"
fi
if [[ "${VERSION_REV}" == "" || "${VERSION_REV}" == "-dev" ]]; then
buildManifest ${shortName} "${FULL_VERSION}"
buildManifest ${shortName} "${LATEST_VERSION}"
else
buildManifest ${shortName} "${FULL_VERSION}"
buildManifest ${shortName} "${VERSION_MAJOR}"
buildManifest ${shortName} "${LATEST_VERSION}"
fi
}
if (( $# < 1 )); then
echo "[Error] Illegal number of arguments."
echo "Usage: $0 [all|cardano-node|cardano-tools|mmonit|monit] [push]"
exit 1
fi
shortName=$1
push=$2
if [[ $shortName == "all" ]]; then
buildImage "cardano-node"
buildImage "cardano-tools"
buildImage "mmonit"
buildImage "monit"
elif [[ $shortName == "cardano" ]]; then
buildImage "cardano-node"
buildImage "cardano-tools"
else
buildImage $shortName
fi