internal/gaby: limit deploy script to devel
Now that we have a Cloud Build trigger to deploy to prod, the
deploy-cloud-run.sh script should be used only for devel.
Hardwire that.
Change-Id: I8833ca9612d700508454d75bc359bca20bf235c6
Reviewed-on: https://go-review.googlesource.com/c/oscar/+/609138
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
diff --git a/internal/gaby/deploy-cloud-run.sh b/internal/gaby/deploy-cloud-run.sh
index d4034e7..fd5c3f2 100755
--- a/internal/gaby/deploy-cloud-run.sh
+++ b/internal/gaby/deploy-cloud-run.sh
@@ -2,16 +2,9 @@
set -e
-# This script deploys gaby to Cloud Run.
-# It takes a single argument, the Firestore database name, which
-# is also the suffix of the Cloud Run service name.
-#
-# Example:
-#
-# deploy-cloud-run.sh devel
-#
# This command builds a docker container for gaby that refers the Firestore "devel"
# database, and deploys it as the Cloud Run service "gaby-devel".
+# It takes no arguments.
#
# The script requires the OSCAR_PROJECT environment variable to be set to the project
# ID of the GCP project hosting Oscar.
@@ -19,10 +12,6 @@
# The script passes false for both the -enablesync and -enablechanges flags to gaby.
# Edit the script to pass true for one or both of them.
#
-# You should avoid using this script to deploy to prod unless you know what you are doing.
-# And you should avoid deploying anywhere from a workspace with uncommitted files;
-# when debugging, it may be impossible to retrieve the exact source that produced the container.
-#
# This script requires the following GCP permissions, and possibly others:
# Cloud Run Developer
@@ -31,16 +20,12 @@
exit 2
fi
-firestore_db=$1
-case $firestore_db in
- devel|prod);;
- *)
- echo >&2 "usage: $0 FIRESTORE_DB"
- echo >&2 " FIRESTORE_DB must be one of: devel, prod"
- exit 2
-esac
+# Variables must be defined.
+set -u
-image=gcr.io/$OSCAR_PROJECT/gaby:$firestore_db
+region=us-central1
+
+image=gcr.io/$OSCAR_PROJECT/gaby:devel
repo_root=$(git rev-parse --show-toplevel)
@@ -48,12 +33,13 @@
docker build -f internal/gaby/Dockerfile \
-t $image \
- --build-arg FIRESTORE_DB=$firestore_db \
+ --build-arg FIRESTORE_DB=devel \
--build-arg ENABLE_SYNC=false \
--build-arg ENABLE_CHANGES=false \
$repo_root
docker push $image
-gcloud run deploy gaby-$firestore_db --image $image --quiet
+gcloud run deploy gaby-devel --image $image --region $region --quiet
+gcloud run services update-traffic gaby-devel --to-latest --region $region