File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
13# Copyright 2022 Cortex Labs, Inc.
24#
35# 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
3032
3133destination_ecr_prefix=" cortexlabs"
3234destination_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
3441
3542source $ROOT /build/images.sh
3643
3744# create the image repositories
3845for 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
4052done
4153echo
4254
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
2727
2828Run the script below to export images to ECR in the same region and account as your cluster.
2929
30+ The script will automatically create ECR Repositories with prefix ` cortexlabs ` if they don't already exist.
31+
3032Feel free to modify the script if you would like to export the images to a different registry such as a private docker hub.
3133
3234``` bash
You can’t perform that action at this time.
0 commit comments