From 7b39ff021d4cf37b46192f08a64099d04532d2cf Mon Sep 17 00:00:00 2001 From: Yann Defretin Date: Tue, 15 Oct 2019 19:30:30 +0200 Subject: [PATCH] refactoring, deleting useless repetitions --- deploy_cloudrun.sh | 50 ++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/deploy_cloudrun.sh b/deploy_cloudrun.sh index 08c2b91..a593227 100644 --- a/deploy_cloudrun.sh +++ b/deploy_cloudrun.sh @@ -3,41 +3,25 @@ read -p 'Do yo want to delete images on GCR after building CloudRun services ? (y/n) : ' question echo -e "Warning!\nThis can take some time because of the size of images.\n" -if [ "$question" != "${question#[Yy]}" ]; then - for d in gpt2-models/*; do - # Push images to GCR - [ -f "$d" ] && continue - tag=$(echo "$d" | cut -d "/" -f2-) - gcloud builds submit "$d" --tag "gcr.io/deep-learning-254808/$tag" +for d in gpt2-models/*; do - # Create CloudRun services - gcloud beta run deploy "$tag" \ - --image "gcr.io/deep-learning-254808/$tag" \ - --platform=managed \ - --allow-unauthenticated \ - --region=us-east1 \ - --concurrency=1 \ - --memory=2Gi + # Push images to GCR + [ -f "$d" ] && continue + tag=$(echo "$d" | cut -d "/" -f2-) + gcloud builds submit "$d" --tag "gcr.io/deep-learning-254808/$tag" - # Delete images on GCR to save money? - gcloud container images delete "gcr.io/deep-learning-254808/$tag" - done -else - for d in gpt2-models/*; do - # Push images to GCR - [ -f "$d" ] && continue - tag=$(echo "$d" | cut -d "/" -f2-) - gcloud builds submit "$d" --tag "gcr.io/deep-learning-254808/$tag" + # Create CloudRun services + gcloud beta run deploy "$tag" \ + --image "gcr.io/deep-learning-254808/$tag" \ + --platform=managed \ + --allow-unauthenticated \ + --region=us-east1 \ + --concurrency=1 \ + --memory=2Gi - # Create CloudRun services - gcloud beta run deploy "$tag" \ - --image "gcr.io/deep-learning-254808/$tag" \ - --platform=managed \ - --allow-unauthenticated \ - --region=us-east1 \ - --concurrency=1 \ - --memory=2Gi - done -fi + # Delete images on GCR to save money? + [ "$question" != "${question#[Yy]}" ] && gcloud container images delete "gcr.io/deep-learning-254808/$tag" + +done echo -e "\nDone!\nURLs of Cloud Run services:\n\n$(gcloud beta run services list --platform=managed |grep -Po 'https.?://\S+')"