-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiarch.sh
executable file
·75 lines (61 loc) · 1.33 KB
/
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
#!/bin/bash
#
# Script to generate a multi-architecture docker image from the
# individual images
#
# SYNTAX
#
# multiarch.sh imagename version architectures...
#
# Where arch is one of the following: amd64 arm32v6 arm32v7 arm64v8
#
# image should be the full name, e.g. area51/nre-feeds:latest or area51/nre-feeds:0.2
# This script will append -{microservice}-{arch} to that name
#
IMAGE=$1
shift
VERSION=$1
shift
MODULE=$1
shift
# The final multiarch image
if [ "$MODULE" = "Build" ]
then
MULTIIMAGE=${IMAGE}:${VERSION}
else
MULTIIMAGE=${IMAGE}:${MODULE}-${VERSION}
fi
. functions.sh
CMD="docker manifest create -a ${MULTIIMAGE}"
for ARCH in $@
do
if [ "$MODULE" = "Build" ]
then
TAG="${IMAGE}:${ARCH}-${VERSION}"
else
TAG="${IMAGE}:${MODULE}-${ARCH}-${VERSION}"
fi
CMD="$CMD $TAG"
done
execute $CMD
for ARCH in $@
do
if [ "$MODULE" = "Build" ]
then
TAG="${IMAGE}:${ARCH}-${VERSION}"
else
TAG="${IMAGE}:${MODULE}-${ARCH}-${VERSION}"
fi
# ensure this node has the latest image for this architecture
execute "docker pull ${TAG}"
CMD="docker manifest annotate"
CMD="$CMD --os linux"
CMD="$CMD --arch $(goarch $ARCH)"
if [ "$(goarch $ARCH)" = "arm" ]
then
CMD="$CMD --variant v$(goarm $ARCH)"
fi
CMD="$CMD $MULTIIMAGE $TAG"
execute $CMD
done
execute docker manifest push -p $MULTIIMAGE