-
Notifications
You must be signed in to change notification settings - Fork 31
/
cloudbuild-prod.yaml
78 lines (74 loc) · 2.35 KB
/
cloudbuild-prod.yaml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#The script is invoked manually with all settings provided in the secret
#It assumes that DB is created before the script run
#Inorder to deploy a service, pass sha-id of the already built image
#Command: gcloud builds submit --config=cloudbuild-prod.yaml --substitutions=SHORT_SHA=<sha-id>
steps:
- id: "apply migrations"
name: "gcr.io/google-appengine/exec-wrapper"
dir: "server"
args:
[
"-i",
"${_REGION}-${_ARTIFACT_REGISTRY_DOMAIN}/${PROJECT_ID}/${_REPO_NAME}/${_IMAGE_NAME}:${SHORT_SHA}",
"-s",
"${PROJECT_ID}:${_REGION}:${_SQL_INSTANCE_NAME}",
"-e",
"SETTINGS_SECRETS_NAME=${_SECRET_SETTINGS_NAME}",
"--",
"python",
"manage.py",
"migrate",
]
- id: "collect static"
name: "gcr.io/google-appengine/exec-wrapper"
dir: "server"
args:
[
"-i",
"${_REGION}-${_ARTIFACT_REGISTRY_DOMAIN}/${PROJECT_ID}/${_REPO_NAME}/${_IMAGE_NAME}:${SHORT_SHA}",
"-s",
"${PROJECT_ID}:${_REGION}:${_SQL_INSTANCE_NAME}",
"-e",
"SETTINGS_SECRETS_NAME=${_SECRET_SETTINGS_NAME}",
"--",
"python",
"manage.py",
"collectstatic",
"--verbosity",
"2",
"--no-input",
]
- id: "deploy cloud run"
name: "gcr.io/cloud-builders/gcloud"
args:
[
"run",
"deploy",
"${_CLOUD_RUN_SERVICE_NAME}",
"--platform",
"managed",
"--region",
"${_REGION}",
"--image",
"${_REGION}-${_ARTIFACT_REGISTRY_DOMAIN}/${PROJECT_ID}/${_REPO_NAME}/${_IMAGE_NAME}:${SHORT_SHA}",
"--add-cloudsql-instances",
"${PROJECT_ID}:${_REGION}:${_SQL_INSTANCE_NAME}",
"--set-env-vars",
"SETTINGS_SECRETS_NAME=${_SECRET_SETTINGS_NAME}",
"--allow-unauthenticated",
"--min-instances",
"${_CLOUD_RUN_MIN_INSTANCES}"
]
substitutions:
_REGION: us-west1
_ARTIFACT_REGISTRY_DOMAIN: docker.pkg.dev
_REPO_NAME: medperf-repo
_IMAGE_NAME: medperf-api
_CLOUD_RUN_SERVICE_NAME: medperf-api-cb-prod
_CLOUD_RUN_MIN_INSTANCES: '1'
_SECRET_SETTINGS_NAME: django-prod-settings
_SQL_INSTANCE_NAME: medperf-dev
##Settings specific for Prod##
##All DB settings are picked from the secret if DEPLOY_ENV is set to gcp-prod in secrets.
options:
dynamic_substitutions: true