-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpush-all.sh
More file actions
executable file
·67 lines (56 loc) · 1.74 KB
/
push-all.sh
File metadata and controls
executable file
·67 lines (56 loc) · 1.74 KB
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
#!/bin/bash
#####################
# SETUP
#########
# Fail fast
set -e
# Assume PWD is root of the repo
source ./scripts/env.sh
# Required arguments
export BUILD_NUMBER="${BUILD_NUMBER:?BUILD_NUMBER must be set}"
# Print all image:tag combinations created by the current build
# using the build-number label, and excluding dangling images
# that may be created by multi-stage builds.
current_build_tags() {
docker images \
--filter label=org.label-schema.build-number="${BUILD_NUMBER:-local}" \
--filter dangling=false \
--format "{{.Repository}}" |
sort -u
}
#####################
# LOGIN
#
# When called by CI, this is already done as part of the ci.sh build.
# Logic is preserved here simply so push-all.sh can be called independently
# if needed.
#########
./scripts/docker-login.sh
#####################
# PUSH
#########
# HACK : unconditionally push to latest
#DOCKER_TAG="${DOCKER_TAG} latest"
source ./scripts/remove-tag.sh
current_build_tags | grep -Ev "$DOCKER_REPOSITORY/(base|.*-chain)" |
while read image;
do
echo "$image"
for tag in ${DOCKER_TAG};
do
# re-tag images; adds build number to avoid race condition between builds
ARMTAG="$BUILD_NUMBER-arm64"
AMDTAG="$BUILD_NUMBER-amd64"
docker tag "$image:local-arm64" "$image:$ARMTAG"
docker tag "$image:local-amd64" "$image:$AMDTAG"
# push temporary image tags
docker push "$image:$ARMTAG"
docker push "$image:$AMDTAG"
# couple the temporary tags into one manifest
docker manifest create "$image:$tag" --amend "$image:$ARMTAG" --amend "$image:$AMDTAG"
docker manifest push "$image:$tag"
# remove temporary tags
remove_tag "$image" "$ARMTAG"
remove_tag "$image" "$AMDTAG"
done
done