Until recently, this is how you deployed code to Cloud Run:
- Define your container-based app with a Dockerfile.
- Build the container image and push it to the Container Registry (typically with Cloud Build).
- Deploy the container image to Cloud Run.
Back in December, we announced the beta release of source-based deployments for Cloud Run. This combines steps 2 and 3 above into a single command. Perhaps more importantly, it also eliminates the need for a Dockerfile for supported language versions.
Now you can finally go from source code to a running Cloud Run service with a single command and without having to worry about the complexities of creating a container image. It’s nice to finally see the Cloud Run deployment experience on par with Cloud Functions and App Engine.
Pleased to see that the source-based deployment is now generally available, I decided to take an existing sample of mine and convert it to use the source-based deployment.
The old deployment experience
Previously, here’s how I deployed the app, a simple .NET Core 3.0 web application.
First, I had to author a Dockerfile, which is not trivial for more complex applications.
Then, I built the container image with Cloud Build: