Skip to content

Instantly share code, notes, and snippets.

@Timtech4u
Created June 22, 2019 02:24
Show Gist options
  • Save Timtech4u/27715bb926b57dbf08d0e5fc0e4ae9bf to your computer and use it in GitHub Desktop.
Save Timtech4u/27715bb926b57dbf08d0e5fc0e4ae9bf to your computer and use it in GitHub Desktop.
Multi Staged Deployment with Cloud Build
steps:
# build the container image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/projectz-239507/app', '.']
# push the container image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/projectz-239507/app']
# create database
- name: 'gcr.io/cloud-builders/gcloud'
args: ['sql', 'databases', 'create', 'mydb', '--instance', 'ddd']
# create cloud bucket
- name: 'gcr.io/cloud-builders/gsutil'
args: ['mb', '-l', 'us-central1', 'gs://mybucket']
# Deploy container image to Cloud Run
- name: 'gcr.io/cloud-builders/gcloud'
args: ['beta', 'run', 'deploy', 'app', '--image', 'gcr.io/projectz-239507/app', '--region', 'us-central1', '--allow-unauthenticated', '--update-env-vars', 'BUCKET=mybucket, DATABASE=mydb']
images:
- gcr.io/projectz-239507/app
timeout: 1200s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment