forked from schulterklopfer/cyphernode_welcome
-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-build.sh
executable file
·59 lines (40 loc) · 2.02 KB
/
docker-build.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
#!/bin/sh
# Must be logged to docker hub:
# docker login -u cyphernode
# Must enable experimental cli features
# "experimental": "enabled" in ~/.docker/config.json
image() {
local arch=$1
echo "Building and pushing cyphernode/app_welcome for $arch tagging as ${version}..."
docker build -t cyphernode/app_welcome:${arch}-${version} . \
&& docker push cyphernode/app_welcome:${arch}-${version}
return $?
}
manifest() {
echo "Creating and pushing manifest for cyphernode/app_welcome for version ${version}..."
docker manifest create cyphernode/app_welcome:${version} \
cyphernode/app_welcome:${x86_docker}-${version} \
cyphernode/app_welcome:${arm_docker}-${version} \
cyphernode/app_welcome:${aarch64_docker}-${version} \
&& docker manifest annotate cyphernode/app_welcome:${version} cyphernode/app_welcome:${arm_docker}-${version} --os linux --arch ${arm_docker} \
&& docker manifest annotate cyphernode/app_welcome:${version} cyphernode/app_welcome:${x86_docker}-${version} --os linux --arch ${x86_docker} \
&& docker manifest annotate cyphernode/app_welcome:${version} cyphernode/app_welcome:${aarch64_docker}-${version} --os linux --arch ${aarch64_docker} \
&& docker manifest push -p cyphernode/app_welcome:${version}
return $?
}
x86_docker="amd64"
arm_docker="arm"
aarch64_docker="arm64"
# Build amd64 and arm64 first, building for arm will trigger the manifest creation and push on hub
#arch_docker=${arm_docker}
#arch_docker=${aarch64_docker}
arch_docker=${x86_docker}
version="v0.2.4"
echo "arch_docker=$arch_docker"
image ${arch_docker}
[ $? -ne 0 ] && echo "Error" && exit 1
[ "${arch_docker}" = "${x86_docker}" ] && echo "Built and pushed ${arch_docker} only" && exit 0
[ "${arch_docker}" = "${aarch64_docker}" ] && echo "Built and pushed ${arch_docker} only" && exit 0
[ "${arch_docker}" = "${arm_docker}" ] && echo "Built and pushed images, now building and pushing manifest for all archs..."
manifest
[ $? -ne 0 ] && echo "Error" && exit 1