-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
72 lines (66 loc) · 1.99 KB
/
cloudbuild.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
steps:
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:slim"
id: "setup-envs"
entrypoint: "bash"
args:
- "-c"
- |
printf "%s" "$$APP_ENGINE_ENVS" > ./env.sh
printf "%s" "$$DJANGO_STORAGES_GCS_KEY" > ./django-storages-gcs-key.json
chmod +x ./env.sh
secretEnv: ["APP_ENGINE_ENVS", "DJANGO_STORAGES_GCS_KEY"]
waitFor: ["-"]
- name: "python:3.10-slim"
id: "install-deps"
entrypoint: "bash"
args:
- "-c"
- |
python3 -m pip install -r requirements.txt --user
waitFor: [ "-" ]
- name: "python:3.10-slim"
id: "collect-statics"
entrypoint: "bash"
args:
- "-c"
- |
source ./env.sh
python3 ./manage.py collectstatic --noinput
waitFor: ["setup-envs", "install-deps"]
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:slim"
id: "deploy"
entrypoint: "bash"
args:
- "-c"
- |
source ./env.sh
gcloud app deploy
waitFor: ["collect-statics"]
- name: "gcr.io/cloud-builders/wget"
id: "install-proxy"
entrypoint: "bash"
args:
- "-c"
- |
wget -O /workspace/cloud_sql_proxy \
"https://storage.googleapis.com/cloudsql-proxy/v1.19.1/cloud_sql_proxy.linux.386" \
&& chmod +x /workspace/cloud_sql_proxy
waitFor: ["-"]
- name: "python:3.10-slim"
id: "migrate-db"
entrypoint: "bash"
args:
- "-c"
- |
source ./env.sh
export DB_HOST=$$DB_SQL_PROXY
/workspace/cloud_sql_proxy -dir=/workspace -instances=$$DB_CONNECTION_NAME \
& sleep 2 \
&& python3 ./manage.py migrate
waitFor: ["setup-envs", "install-deps", "install-proxy", "deploy"]
availableSecrets:
secretManager:
- versionName: "projects/local-context-hub-staging/secrets/APP_ENGINE_ENVS/versions/latest"
env: "APP_ENGINE_ENVS"
- versionName: "projects/local-context-hub-staging/secrets/django-storages-gcs-key/versions/latest"
env: "DJANGO_STORAGES_GCS_KEY"