-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.sh
50 lines (37 loc) · 1.36 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# to spin up this repo as a Cloud Run service on Google Cloud
# https://cloud.google.com/sdk/gcloud/reference/run/deploy
# region: please see GCP for a full list of regions supported by Cloud Run
# if the flag for "allow unauthenticated" is present, then unauthenticated requests are allowed
# i.e., Allow unauthenticated requests (so that it is publicly available on the web to anyone with the link)
# --ingress internal <------- this will only allow GCP project-internal traffic (e.g. compute instance triggering cloud run)
# region options: us-central1, us-east1, us-east4, us-west1, us-west2, us-west3, us-west4
######################################
# navigate into the app
cd app
# GCP project ID
PROJECTID=''
# NOTE: cloud run does not allow underscores (_)
SERVICENAME=''
# cloud sql instance name, if applicable
CLOUDSQLINSTANCE=''
# cloud build on gcp
gcloud builds submit --tag "gcr.io/$PROJECTID/$SERVICENAME"
# deploy as cloud run service
gcloud run deploy \
$SERVICENAME \
--region us-west1 \
--concurrency 100 \
--cpu 4 \
--memory 16G \
--min-instances 0 \
--max-instances 2 \
--port 8080 \
--timeout 3600 \
--allow-unauthenticated \
--ingress all \
--image gcr.io/$PROJECTID/$SERVICENAME --platform managed \
--add-cloudsql-instances $CLOUDSQLINSTANCE \
--update-env-vars INSTANCE_CONNECTION_NAME="$CLOUDSQLINSTANCE"
# done
echo "Cloud Run deployed."