.NET 6 support in Google Cloud Buildpacks and Cloud Run


I really like the idea of containers, a reproducible context that our apps can rely on. However, I really dislike having to create a Dockerfile to define my container images. I always need to copy & paste it from somewhere and it takes me some time to get it right.

That’s why I like using Google Cloud Buildpacks to build containers without having to worry about a Dockerfile.

I’m happy to announce that, as of yesterday, Google Cloud Buildpacks now supports .NET 6 (the latest LTS version) apps as well!

What does this mean for you?

Here’s a .NET 6 Hello World app with a Dockerfile.

You can build the container image and deploy to Cloud Run in one step:

gcloud run deploy $SERVICE_NAME \
  --source . \
  --allow-unauthenticated \
  --region $REGION

This uses the .NET buildpack and the Dockerfile to build the container image and then deploy to Cloud Run:

This command is equivalent to running `gcloud builds submit --tag [IMAGE] .` and `gcloud run deploy dotnet6 --image [IMAGE]`

Building using Dockerfile and deploying container to Cloud Run service [dotnet6] in project [dotnet-atamel] region [europe-west1]

Better yet, if you remove the Dockerfile, the .NET buildpack detects the .NET version and builds the image for you:

This command is equivalent to running `gcloud builds submit --pack image=[IMAGE] .` and `gcloud run deploy dotnet6 --image [IMAGE]`

Building using Buildpacks and deploying container to Cloud Run service [dotnet6] in project [knative-atamel] region [europe-west1]

This not only works for .NET 6 but for .NET 5 and all the .NET versions after .NET Core 1.0!


Feel free to reach out to me on Twitter @meteatamel for any questions/feedback.


See also