-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
63 lines (60 loc) · 2.19 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
steps:
- name: 'gcr.io/kaniko-project/executor:latest'
id: 'Build & Push Image'
args:
- '--destination=us.gcr.io/$PROJECT_ID/$_IMAGE_NAME:$SHORT_SHA'
- '--destination=us.gcr.io/$PROJECT_ID/$_IMAGE_NAME:latest'
- '--dockerfile=Dockerfile'
- '--context=.'
- '--cache=true'
- '--cache-ttl=120h'
- id: 'Deploy to Cloud Run'
name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud run deploy $_SERVICE_NAME \
--image=us.gcr.io/$PROJECT_ID/$_IMAGE_NAME:$SHORT_SHA \
--region=$_REGION_NAME \
--platform managed \
--allow-unauthenticated \
--add-cloudsql-instances $PROJECT_ID:$_REGION_NAME:$_INSTANCE_NAME \
--port=5000 \
--set-env-vars "API_VERSION_LATEST=v1" \
--set-env-vars "PROJECT_NAME=$_PROJECT_NAME" \
--set-env-vars "PROJECT_ENVIRONMENT=$_PROJECT_ENVIRONMENT" \
--set-env-vars "USE_CLOUD_SQL=$_USE_CLOUD_SQL" \
--set-env-vars "MYSQL_INSTANCE_CONNECTION_NAME=$PROJECT_ID:$_REGION_NAME:$_INSTANCE_NAME" \
--set-env-vars "MYSQL_USER=$_MYSQL_USER" \
--set-env-vars "MYSQL_PASSWORD=$_MYSQL_PASSWORD" \
--set-env-vars "MYSQL_DATABASE=$_MYSQL_DATABASE" \
--set-env-vars "MYSQL_PRIVATE_IP=$_MYSQL_PRIVATE_IP" \
--set-env-vars "SENTRY_DSN=$_SENTRY_DSN" \
--set-env-vars "SERVER_NAME=$_SERVER_NAME" \
--set-env-vars "SERVER_HOST=$_SERVER_HOST" \
--set-env-vars "FIRST_SUPERUSER_EMAIL=$_FIRST_SUPERUSER_EMAIL" \
--set-env-vars "FIRST_SUPERUSER_PASSWORD=$_FIRST_SUPERUSER_PASSWORD"
substitutions:
# Service specific env vars:
_PROJECT_NAME: 'Perseus FastAPI'
_PROJECT_ENVIRONMENT: 'production'
_SENTRY_DSN: ''
_SERVER_NAME: ''
_SERVER_HOST: ''
# Cloud MySQL specific env vars:
_USE_CLOUD_SQL: 'true'
_MYSQL_USER: ''
_MYSQL_PASSWORD: ''
_MYSQL_DATABASE: ''
_MYSQL_PRIVATE_IP: 'false'
# User specific env vars:
_FIRST_SUPERUSER_EMAIL: ''
_FIRST_SUPERUSER_PASSWORD: ''
# Google Cloud Build / Run variables:
_IMAGE_NAME: observerly-perseus
_REGION_NAME: us-central1
_SERVICE_NAME: perseus
_INSTANCE_NAME: perseus
options:
logging: CLOUD_LOGGING_ONLY