File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
1
3
# Copyright 2022 Cortex Labs, Inc.
2
4
#
3
5
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,13 +32,23 @@ source_registry=quay.io/cortexlabs # this can also be docker.io/cortexlabs
30
32
31
33
destination_ecr_prefix=" cortexlabs"
32
34
destination_registry=" ${aws_account_id} .dkr.ecr.${ecr_region} .amazonaws.com/${destination_ecr_prefix} "
33
- aws ecr get-login-password --region $ecr_region | docker login --username AWS --password-stdin $destination_registry
35
+
36
+ if [[ -f $HOME /.docker/config.json && $( cat $HOME /.docker/config.json | grep " ecr-login" | wc -l) -ne 0 ]]; then
37
+ echo " skipping docker login because you are using ecr-login with Amazon ECR Docker Credential Helper"
38
+ else
39
+ aws ecr get-login-password --region $ecr_region | docker login --username AWS --password-stdin $destination_registry
40
+ fi
34
41
35
42
source $ROOT /build/images.sh
36
43
37
44
# create the image repositories
38
45
for image in " ${all_images[@]} " ; do
39
- aws ecr create-repository --repository-name=$destination_ecr_prefix /$image --region=$ecr_region || true
46
+ repository_name=$destination_ecr_prefix /$image
47
+ if aws ecr describe-repositories --repository-names=$repository_name --region=$ecr_region > /dev/null 2>&1 ; then
48
+ echo " repository '$repository_name ' already exists"
49
+ else
50
+ aws ecr create-repository --repository-name=$repository_name --region=$ecr_region | cat
51
+ fi
40
52
done
41
53
echo
42
54
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ git clone --depth 1 --branch v$CORTEX_VERSION https://github.com/cortexlabs/cort
27
27
28
28
Run the script below to export images to ECR in the same region and account as your cluster.
29
29
30
+ The script will automatically create ECR Repositories with prefix ` cortexlabs ` if they don't already exist.
31
+
30
32
Feel free to modify the script if you would like to export the images to a different registry such as a private docker hub.
31
33
32
34
``` bash
You can’t perform that action at this time.
0 commit comments