Skip to content

Commit

Permalink
fix: export_images.sh (#2424)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluuewhale authored Apr 23, 2022
1 parent 46bc56f commit 231cbb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 14 additions & 2 deletions dev/export_images.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

# Copyright 2022 Cortex Labs, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -30,13 +32,23 @@ source_registry=quay.io/cortexlabs # this can also be docker.io/cortexlabs

destination_ecr_prefix="cortexlabs"
destination_registry="${aws_account_id}.dkr.ecr.${ecr_region}.amazonaws.com/${destination_ecr_prefix}"
aws ecr get-login-password --region $ecr_region | docker login --username AWS --password-stdin $destination_registry

if [[ -f $HOME/.docker/config.json && $(cat $HOME/.docker/config.json | grep "ecr-login" | wc -l) -ne 0 ]]; then
echo "skipping docker login because you are using ecr-login with Amazon ECR Docker Credential Helper"
else
aws ecr get-login-password --region $ecr_region | docker login --username AWS --password-stdin $destination_registry
fi

source $ROOT/build/images.sh

# create the image repositories
for image in "${all_images[@]}"; do
aws ecr create-repository --repository-name=$destination_ecr_prefix/$image --region=$ecr_region || true
repository_name=$destination_ecr_prefix/$image
if aws ecr describe-repositories --repository-names=$repository_name --region=$ecr_region >/dev/null 2>&1; then
echo "repository '$repository_name' already exists"
else
aws ecr create-repository --repository-name=$repository_name --region=$ecr_region | cat
fi
done
echo

Expand Down
2 changes: 2 additions & 0 deletions docs/clusters/advanced/self-hosted-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ git clone --depth 1 --branch v$CORTEX_VERSION https://github.com/cortexlabs/cort

Run the script below to export images to ECR in the same region and account as your cluster.

The script will automatically create ECR Repositories with prefix `cortexlabs` if they don't already exist.

Feel free to modify the script if you would like to export the images to a different registry such as a private docker hub.

```bash
Expand Down

0 comments on commit 231cbb6

Please sign in to comment.