|
| 1 | +# Copyright 2021 Cortex Labs, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +set -euo pipefail |
| 16 | + |
| 17 | +# usage: ./dev/export_images.sh <region> <aws account id> |
| 18 | +# e.g. ./dev/export_images.sh us-east-1 123456789 |
| 19 | + |
| 20 | +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)" |
| 21 | + |
| 22 | +# CORTEX_VERSION |
| 23 | +cortex_version=0.34.0 |
| 24 | + |
| 25 | +# user set variables |
| 26 | +ecr_region=$1 |
| 27 | +aws_account_id=$2 |
| 28 | + |
| 29 | +source_registry=quay.io/cortexlabs # this can also be docker.io/cortexlabs |
| 30 | + |
| 31 | +destination_ecr_prefix="cortexlabs" |
| 32 | +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 |
| 34 | + |
| 35 | +source build/images.sh |
| 36 | + |
| 37 | +# create the image repositories |
| 38 | +for image in "${all_images[@]}"; do |
| 39 | + aws ecr create-repository --repository-name=$destination_ecr_prefix/$image --region=$ecr_region || true |
| 40 | +done |
| 41 | +echo |
| 42 | + |
| 43 | +cuda=("10.0" "10.1" "10.1" "10.2" "10.2" "11.0" "11.1") |
| 44 | +cudnn=("7" "7" "8" "7" "8" "8" "8") |
| 45 | + |
| 46 | +# pull the images from source registry and push them to ECR |
| 47 | +for image in "${all_images[@]}"; do |
| 48 | + # copy the different cuda/cudnn variations of the python handler image |
| 49 | + if [ "$image" = "python-handler-gpu" ]; then |
| 50 | + for i in "${!cuda[@]}"; do |
| 51 | + full_image="$image:$cortex_version-cuda${cuda[$i]}-cudnn${cudnn[$i]}" |
| 52 | + echo "copying $full_image from $source_registry to $destination_registry" |
| 53 | + skopeo copy --src-no-creds "docker://$source_registry/$full_image" "docker://$destination_registry/$full_image" |
| 54 | + echo |
| 55 | + done |
| 56 | + else |
| 57 | + echo "copying $image:$cortex_version from $source_registry to $destination_registry" |
| 58 | + skopeo copy --src-no-creds "docker://$source_registry/$image:$cortex_version" "docker://$destination_registry/$image:$cortex_version" |
| 59 | + echo |
| 60 | + fi |
| 61 | +done |
| 62 | +echo "done ✓" |
0 commit comments