❯ Guillaume Laforge

Serverless tip #3 — Use the Cloud Run button on your Git repository to deploy your project in a click

Requirements:

  • an existing Google Cloud Platform account
  • a Git or Github repository containing your project
  • your project can have a Dockerfile (but not mandatory)

With Cloud Run, you can easily deploy a container image and let it scale up and down as needed, in a serverless fashion:

  • No need to focus on infrastructure (provisioning servers, clusters, upgrading OS, etc.)
  • Your application can scale transparently from 0 to 1, and from 1 to n (no need for a pager when your app is featured on Hackernews)
  • You pay as you go, proportionally to the usage

If your project is hosted on Github, for example, how can you help users get started with your project? You usually explain all the steps needed to build a container image, or where to fetch a pre-made image from a hub, and then steps to actually deploy that image on the platform. But thanks to the Cloud Run button, you can add a button image on your README.md page for instance, and then users can click on it and get started with building and deploying to a GCP project automagically.

If the Git repository contains a Dockerfile, it will be built using the docker build command. Otherwise, the CNCF Buildpacks (with the pack build command) will be used to build the repository.

The Cloud Run button github project gives extra information on the parameterization of the deploy URL of the button, for example if you want to specify a particular branch or directory.

More information