-
Notifications
You must be signed in to change notification settings - Fork 3
/
manifest.sh
executable file
·79 lines (71 loc) · 2.24 KB
/
manifest.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
#!/bin/bash
#
# Docker multi-platform manifest creator
#
# Assembles and pushes a Docker manifest for Docker Hub (default).
# Can either be used standalone or be invoked by Travis CI.
#
# Optimize shell for safety.
set -o errexit -o noclobber -o nounset -o pipefail
# Offer usage info.
show_help() {
cat << EOF
Usage: ${0##*/} -h [-bp]
Create and publish Docker manifest.
-b build Docker manifest
-h display this help and exit
-p push Docker manifest to Docker Hub
EOF
}
# Initialize variables.
DOCKER_REPO=${TRAVIS_REPO_SLUG:-"renemarc/balena-flic"}
MANIFEST_TAG="latest"
DOCKER_BUILD=false
DOCKER_PUSH=false
# Parse command-line arguments.
OPTIND=1
while getopts ":hbp" opt; do
case $opt in
b)
DOCKER_BUILD=true
;;
h)
show_help
exit 1
;;
p)
DOCKER_PUSH=true
;;
\?)
printf "Invalid option: -%s\nSee ${0##*/} -h for usage info.\n" "$OPTARG">&2
;;
esac
done
if (( $# == 0 )); then
show_help >&2
exit 1
fi
# Create manifest.
if [ "$DOCKER_BUILD" = true ]; then
set -o xtrace
{ echo "Creating manifest $DOCKER_REPO:$MANIFEST_TAG from Docker Hub images:"; } 2> /dev/null
docker --debug manifest create "$DOCKER_REPO:$MANIFEST_TAG" \
"$DOCKER_REPO:aarch64" \
"$DOCKER_REPO:armv7hf" \
"$DOCKER_REPO:rpi" \
"$DOCKER_REPO:i386" \
"$DOCKER_REPO:amd64"
{ echo "Anotating manifest with architecture information:"; } 2> /dev/null
docker --debug manifest annotate "$DOCKER_REPO:$MANIFEST_TAG" "$DOCKER_REPO:aarch64" --os linux --arch arm64 --variant v8
docker --debug manifest annotate "$DOCKER_REPO:$MANIFEST_TAG" "$DOCKER_REPO:armv7hf" --os linux --arch arm --variant v7
docker --debug manifest annotate "$DOCKER_REPO:$MANIFEST_TAG" "$DOCKER_REPO:rpi" --os linux --arch arm --variant v6
docker --debug manifest annotate "$DOCKER_REPO:$MANIFEST_TAG" "$DOCKER_REPO:i386" --os linux --arch 386
docker --debug manifest annotate "$DOCKER_REPO:$MANIFEST_TAG" "$DOCKER_REPO:amd64" --os linux --arch amd64
set +o xtrace
fi
# Push manifest to Docker Hub.
if [ "$DOCKER_PUSH" = true ]; then
set -o xtrace
{ echo "Pushing manifest $DOCKER_REPO:$MANIFEST_TAG to Docker Hub:"; } 2> /dev/null
docker --debug manifest push --purge "$DOCKER_REPO:$MANIFEST_TAG"
fi