Deploying code to production directly from your dev machine can lead to unforeseen issues: the code might have local changes, the process is manual and error-prone, and tests can be bypassed. And later on, it makes it impossible to understand what actual code is running in production. A best practice for avoiding these hardships is to continuously deploy your code when changes are pushed to a branch of your source repository.

As we announced at Google Cloud Next ‘20: OnAir, Cloud Run now allows you to set up continuous deployment in just a few clicks: From the Cloud Run user interface, you can now easily connect to your Git repository and set up continuous deployment to automatically build and deploy your code to your Cloud Run and Cloud Run or Anthos services. This feature is available for both new and existing services.

You can select any repository that includes a Dockerfile or code written in Go, Node.js, Java, Python, and .NET. Under the hood, the continuous deployment setup process configures a Cloud Build trigger that builds the code into a container using Docker or Google Cloud Buildpacks, pushes it to Google Container Registry, and deploys it to your Cloud Run service. You can later customize this by adding steps to the Cloud Build trigger configuration, for example adding unit or integration tests before deploying.

By default, your code is automatically built and deployed to a new Cloud Run revision, but you can decide if it should receive 100% of the incoming traffic immediately or not, and later gradually migrate traffic using the newly added traffic controls.

With Continuous Deployment set up, the Cloud Run service detail page shows relevant in-context information:

  • A link to the exact commit in the Git repository that was used for this deployment
  • A link to the build logs and the build trigger that created this revision / container.
  • A quick preview of the health of the latest builds.
cloud run gcp console.jpg

Pushing your code directly to production was never a good idea. Now, Cloud Run makes it easy for you to embrace best practices like continuous deployment. Give it a try at http://cloud.run/.

Leave a Reply