forked from Consensys/quorum-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush
executable file
·59 lines (46 loc) · 1.41 KB
/
push
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/bash
# Pushes built images to AWS' ECR (Elastic Container Registry).
#
# Requires aws-cli, jq, and docker.
#
# NOTE: While running this script, if
#
# (1) aws-cli says that it doesn't recognize `--no-include-email`
# or (2) docker requires an email (via `-e`)
#
# then update both aws-cli and docker and try running this again.
#
set -euo pipefail
REGION=us-west-2
IMAGES=(quorum constellation quorum-aws)
# Authenticate docker client with ECR:
eval `aws ecr get-login --region ${REGION} --no-include-email` >/dev/null
existing_repository() {
name=$1
(aws ecr describe-repositories --repository-names "$name" 2>/dev/null | jq -r '.repositories[0].repositoryUri') || echo ""
}
create_repository() {
name=$1
aws ecr create-repository --repository-name "${image}" | jq -r '.repository.repositoryUri'
}
# Tag and push each image:
for image in ${IMAGES[@]}
do
echo "pushing $image"
echo " checking for existing ${image} repository"
repository=$(existing_repository $image)
if [[ -z "$repository" ]]
then
echo " existing repository not found. creating new repository"
repository=$(create_repository $image)
echo " created repository ${image}"
else
echo " existing repository is $repository"
fi
echo " tagging image $image"
docker tag ${image}:latest ${repository}:latest
echo " pushing image $image to ECR"
docker push ${repository}:latest
echo " done"
echo
done