56 lines
1.4 KiB
YAML
56 lines
1.4 KiB
YAML
# Cloud Build configuration for building and deploying to Cloud Run
|
|
#
|
|
# Usage:
|
|
# gcloud builds submit --config cloudbuild.yaml --project=PROJECT_ID
|
|
#
|
|
# Or use the fabfile:
|
|
# fab deploy
|
|
|
|
substitutions:
|
|
_REGION: {{ cookiecutter.gcp_region }}
|
|
_SERVICE_NAME: {{ cookiecutter.project_slug }}
|
|
_DJANGO_SETTINGS_MODULE: {{ cookiecutter.project_slug }}.settings.cloud_production
|
|
_CLOUD_SQL_INSTANCE: {{ cookiecutter.cloud_sql_project }}:{{ cookiecutter.gcp_region }}:{{ cookiecutter.cloud_sql_instance }}
|
|
_MIN_INSTANCES: "0"
|
|
_MAX_INSTANCES: "1"
|
|
|
|
steps:
|
|
# Build the container image
|
|
- name: 'gcr.io/cloud-builders/docker'
|
|
args:
|
|
- 'build'
|
|
- '-t'
|
|
- 'gcr.io/$PROJECT_ID/${_SERVICE_NAME}'
|
|
- '--cache-from'
|
|
- 'gcr.io/$PROJECT_ID/${_SERVICE_NAME}'
|
|
- '.'
|
|
|
|
# Push the image to Container Registry
|
|
- name: 'gcr.io/cloud-builders/docker'
|
|
args:
|
|
- 'push'
|
|
- 'gcr.io/$PROJECT_ID/${_SERVICE_NAME}'
|
|
|
|
# Deploy to Cloud Run
|
|
- name: 'gcr.io/cloud-builders/gcloud'
|
|
args:
|
|
- 'run'
|
|
- 'deploy'
|
|
- '${_SERVICE_NAME}'
|
|
- '--image'
|
|
- 'gcr.io/$PROJECT_ID/${_SERVICE_NAME}'
|
|
- '--region'
|
|
- '${_REGION}'
|
|
- '--platform'
|
|
- 'managed'
|
|
- '--add-cloudsql-instances'
|
|
- '${_CLOUD_SQL_INSTANCE}'
|
|
- '--set-env-vars'
|
|
- 'DJANGO_SETTINGS_MODULE=${_DJANGO_SETTINGS_MODULE}'
|
|
- '--allow-unauthenticated'
|
|
|
|
images:
|
|
- 'gcr.io/$PROJECT_ID/${_SERVICE_NAME}'
|
|
|
|
timeout: '1200s'
|