Google Cloud Run for Go

Jaana B. Dogan
Apr 10 · 2 min read

Google Cloud recently launched a fully managed container execution environment called Cloud Run. It is an environment specifically for request-driven workloads. It provides autoscaling, scaling down to zero, pretty fast deployments, automatic HTTPS support, global names and more. Google Cloud Run doesn’t have language runtime restrictions as soon as the language runtime is supported on gVisor. It only requires the deployments to expose an HTTP server on a port.

In order to deploy a Go server, we will start with a minimal helloworld HTTP server. The container runtime is expecting the server to listen on $PORT:

In order to build a Docker image, create a multi-stage Dockerfile:

Build and push the image to Google Container Registry:

Then, either from the Cloud Console or terminal, you can create a new service with the built image:

You can use the provided endpoint to access to the service. See the Cloud Run console for logs and other operations.

Google Cloud Run is specifically optimized for request-driven HTTP/HTTPS workloads. The containers can be preempted and migrated, so it is not great if you are planning to use it for long running services. There is no support other than HTTP/HTTPS for now either. See also Cloud Run on GKE if you need more flexibility.

If you have any feedback, please feel free to reach out to jbd@google.com.

Google Cloud Platform - Community

A collection of technical articles published or curated by Google Cloud Platform Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Jaana B. Dogan

Written by

Engineer at Google

Google Cloud Platform - Community

A collection of technical articles published or curated by Google Cloud Platform Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.