Skip to content

Instantly share code, notes, and snippets.

@clarkmcc
Created January 2, 2022 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkmcc/d4594e7c0f852b4596ac52df28cf087b to your computer and use it in GitHub Desktop.
Save clarkmcc/d4594e7c0f852b4596ac52df28cf087b to your computer and use it in GitHub Desktop.
Builds, pushes, and deploys a container image to Google Cloud Run, just set the $PROJECT_NAME variable
steps:
# Build the container image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/$PROJECT_NAME:$SHORT_SHA', '--cache-from', 'gcr.io/$PROJECT_ID/$PROJECT_NAME', '.']
# Push the container image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/$PROJECT_NAME:$SHORT_SHA']
# Deploy to Google Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args: ['run', 'deploy', '$PROJECT_NAME', '--image', 'gcr.io/$PROJECT_ID/$PROJECT_NAME:$SHORT_SHA', '--region', 'us-west1', '--platform', 'managed']
images:
- gcr.io/$PROJECT_ID/$PROJECT_NAME
timeout: 1200s
options:
machineType: N1_HIGHCPU_32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment