|
| 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 |
|
|
0 commit comments