1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17+ CORTEX_VERSION=master
1718
1819set -eo pipefail
1920
@@ -32,7 +33,6 @@ AWS_ACCOUNT_ID=${AWS_ACCOUNT_ID:-}
3233AWS_REGION=${AWS_REGION:- }
3334
3435provider=" undefined"
35- include_slim=" false"
3636positional_args=()
3737while [[ $# -gt 0 ]]; do
3838 key=" $1 "
@@ -42,10 +42,6 @@ while [[ $# -gt 0 ]]; do
4242 shift
4343 shift
4444 ;;
45- --include-slim)
46- include_slim=" true"
47- shift
48- ;;
4945 * )
5046 positional_args+=(" $1 " )
5147 shift
@@ -112,12 +108,9 @@ function create_aws_registry() {
112108function build() {
113109 local image=$1
114110 local tag=$2
115- local dir=" ${ROOT} /images/${image/ -slim } "
111+ local dir=" ${ROOT} /images/${image} "
116112
117113 build_args=" "
118- if [[ " $image " == * " -slim" ]]; then
119- build_args=" --build-arg SLIM=true"
120- fi
121114
122115 tag_args=" "
123116 if [ -n " $GCP_PROJECT_ID " ]; then
@@ -134,10 +127,10 @@ function build() {
134127
135128function cache_builder() {
136129 local image=$1
137- local dir=" ${ROOT} /images/${image/ -slim } "
130+ local dir=" ${ROOT} /images/${image} "
138131
139132 blue_echo " Building $image -builder..."
140- docker build $ROOT -f $dir /Dockerfile -t cortexlabs/$image -builder:latest --target builder
133+ docker build $ROOT -f $dir /Dockerfile -t cortexlabs/$image -builder:$CORTEX_VERSION --target builder
141134 green_echo " Built $image -builder\n"
142135}
143136
@@ -158,10 +151,14 @@ function push() {
158151
159152function build_and_push() {
160153 local image=$1
161- local tag=$2
162154
163155 set -euo pipefail # necessary since this is called in a new shell by parallel
164156
157+ tag=$CORTEX_VERSION
158+ if [ " ${image} " == " python-predictor-gpu" ]; then
159+ tag=" ${CORTEX_VERSION} -cuda10.2-cudnn8"
160+ fi
161+
165162 build $image $tag
166163 push $image $tag
167164}
@@ -176,18 +173,28 @@ function cleanup_ecr() {
176173 echo " cleaning ECR repositories..."
177174 repos=$( aws ecr describe-repositories --output text | awk ' {print $6}' | grep -P " \S" )
178175 echo " $repos " |
179- while IFS= read -r line ; do
180- imageIDs=$( aws ecr list-images --repository-name " $line " --filter tagStatus=UNTAGGED --query " imageIds[*]" --output text)
176+ while IFS= read -r repo ; do
177+ imageIDs=$( aws ecr list-images --repository-name " $repo " --filter tagStatus=UNTAGGED --query " imageIds[*]" --output text)
181178 echo " $imageIDs " |
182179 while IFS= read -r imageId; do
183180 if [ ! -z " $imageId " ]; then
184- echo " Removing from ECR: $line /$imageId "
185- aws ecr batch-delete-image --repository-name " $line " --image-ids imageDigest=" $imageId " > /dev/null;
181+ echo " Removing from ECR: $repo /$imageId "
182+ aws ecr batch-delete-image --repository-name " $repo " --image-ids imageDigest=" $imageId " > /dev/null;
186183 fi
187184 done
188185 done
189186}
190187
188+ function delete_ecr() {
189+ echo " deleting ECR repositories..."
190+ repos=$( aws ecr describe-repositories --output text | awk ' {print $6}' | grep -P " \S" )
191+ echo " $repos " |
192+ while IFS= read -r repo; do
193+ imageIDs=$( aws ecr delete-repository --force --repository-name " $repo " )
194+ echo " deleted: $repo "
195+ done
196+ }
197+
191198function validate_env() {
192199 local provider=$1
193200
@@ -218,7 +225,8 @@ validate_env "$provider"
218225# usage: registry.sh clean --provider aws|gcp
219226if [ " $cmd " = " clean" ]; then
220227 if [ " $provider " = " aws" ]; then
221- cleanup_ecr
228+ delete_ecr
229+ create_aws_registry
222230 fi
223231
224232# usage: registry.sh create --provider/-p aws|gcp
@@ -233,9 +241,9 @@ elif [ "$cmd" = "update-single" ]; then
233241 if [ " $image " = " operator" ] || [ " $image " = " request-monitor" ]; then
234242 cache_builder $image
235243 fi
236- build_and_push $image latest
244+ build_and_push $image
237245
238- # usage: registry.sh update all|dev|api --provider/-p aws|gcp [--include-slim]
246+ # usage: registry.sh update all|dev|api --provider/-p aws|gcp
239247# if parallel utility is installed, the docker build commands will be parallelized
240248elif [ " $cmd " = " update" ]; then
241249 images_to_build=()
@@ -271,17 +279,6 @@ elif [ "$cmd" = "update" ]; then
271279 images_to_build+=( " ${api_images_aws[@]} " " ${api_images_gcp[@]} " )
272280 fi
273281
274- if [ " $include_slim " == " true" ]; then
275- images_to_build+=( " ${api_slim_images_cluster[@]} " )
276- if [ " $provider " == " aws" ]; then
277- images_to_build+=( " ${api_slim_images_aws[@]} " )
278- elif [ " $provider " == " gcp" ]; then
279- images_to_build+=( " ${api_slim_images_gcp[@]} " )
280- elif [ " $provider " == " undefined" ]; then
281- images_to_build+=( " ${api_slim_images_aws[@]} " " ${api_slim_images_gcp[@]} " )
282- fi
283- fi
284-
285282 if [[ " ${images_to_build[@]} " =~ " operator " ]]; then
286283 cache_builder operator
287284 fi
@@ -290,10 +287,10 @@ elif [ "$cmd" = "update" ]; then
290287 fi
291288
292289 if command -v parallel & > /dev/null && [ -n " ${NUM_BUILD_PROCS+set} " ] && [ " $NUM_BUILD_PROCS " != " 1" ]; then
293- provider=$provider is_registry_logged_in=$is_registry_logged_in ROOT=$ROOT registry_push_url=$registry_push_url SHELL=$( type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS build_and_push " {} latest " ::: " ${images_to_build[@]} "
290+ provider=$provider is_registry_logged_in=$is_registry_logged_in ROOT=$ROOT registry_push_url=$registry_push_url SHELL=$( type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS build_and_push " {}" ::: " ${images_to_build[@]} "
294291 else
295292 for image in " ${images_to_build[@]} " ; do
296- build_and_push $image latest
293+ build_and_push $image
297294 done
298295 fi
299296
0 commit comments