-
Notifications
You must be signed in to change notification settings - Fork 20
/
cloudbuild.yaml
62 lines (55 loc) · 2.02 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
steps:
- id: "configuration"
name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', 'gs://$_CONFIG_BUCKET/cloud_config.json', 'frontend/cloud_config.json']
- id: "build"
name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', '$_IMAGE_NAME', '-f', 'Cloud_dockerfile', '.']
timeout: 500s
- id: "image-storage"
name: 'gcr.io/cloud-builders/docker'
args: ['push', '$_IMAGE_NAME']
- id: "proxy-creation"
name: "gcr.io/cloud-builders/docker"
entrypoint: /bin/bash
args:
- "-c"
- |
echo "FROM $_IMAGE_NAME
COPY --from=gcr.io/cloudsql-docker/gce-proxy /cloud_sql_proxy /cloudsql/cloud_sql_proxy" > Dockerfile-proxy;
docker build -f Dockerfile-proxy -t ${_IMAGE_NAME}-proxy .
- id: "migration"
name: "${_IMAGE_NAME}-proxy"
entrypoint: /bin/bash
env:
- "PROJECT_ID=$_PROJECT_ID"
- "USE_CLOUD_SQL_AUTH_PROXY=true"
- "POSTGRES_USER=$_POSTGRES_USER"
- "CALCUS_COMPUTE=true"
secretEnv: ['POSTGRES_PASSWORD']
args:
- '-c'
- |
/cloudsql/cloud_sql_proxy -instances=${_INSTANCE_CONNECTION_NAME}=tcp:${_DATABASE_PORT} & sleep 2;
python manage.py migrate
- id: "main-deployment"
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args: ['run', 'deploy', 'calcus-cloud', '--image', '$_IMAGE_NAME', '--region', 'us-central1', '--update-env-vars=CALCUS_VERSION_HASH=$SHORT_SHA']
- id: "compute-deployment"
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args: ['run', 'deploy', 'calcus-cloud-compute', '--image', '$_IMAGE_NAME', '--region', 'us-central1', '--update-env-vars=CALCUS_VERSION_HASH=$SHORT_SHA']
images:
- $_IMAGE_NAME
options:
dynamic_substitutions: true
logging: CLOUD_LOGGING_ONLY
substitutions:
_IMAGE_NAME: gcr.io/${_PROJECT_REPO}:latest
_INSTANCE_CONNECTION_NAME: ${_PROJECT_ID}:us-central1:calcus-postgres
_DATABASE_PORT: '5432'
availableSecrets:
secretManager:
- versionName: ${_SECRET_REF}
env: 'POSTGRES_PASSWORD'