Powered By GitBook
cloud-run-deploy-in-5mins
Quickly build and deploy a containerized application and deploy it to Cloud Run.
Contributed by the Google Cloud community. Not official Google documentation.
​Cloud Run is now generally available.
Learn more about Cloud Run on the Google website, in this announcement, and in this video.
Software developers today can focus on building applications faster without having to bother about how their code runs in other environments. This is because containerization takes care of bundling applications along with their configuration and dependencies into an efficient way of running it across different environments.
Deploying containers (Docker or Kubernetes) can also be a headache when you have to take care of provisioning the underlying infrastructure. However, Google Cloud provides a way for you to deploy containerized applications to the cloud in a serverless fashion using Cloud Run, which abstracts away the underlying infrastructure and runs and scales your stateless application automatically.

Objective

In this article, we’ll quickly build a containerized application and deploy it to Cloud Run.

Before you begin

    2.
    3.
    Clone your containerized application or copy this example from the author of this tutorial.

Get the sample code

Get the sample code from GitHub Gist.

Build and publish container images

​Cloud Build allows us to build Docker images in the cloud. We just need our project files (which include a Dockerfile).
Run the following command in Cloud Shell to build our Docker image and push the image to Container Registry:
1
gcloud builds submit --tag gcr.io/[PROJECT_ID]/demo-image .
Copied!
Replace [PROJECT_ID] with your actual project ID value.
Note that if you’re building larger images, you can pass a timeout parameter such as --timeout=600s as part of this command.

Deploy to Cloud Run

Deploy our image from Cloud Shell using the following command:
1
gcloud beta run deploy demo-app --image gcr.io/[PROJECT_ID]/demo-image --region us-central1 --platform managed --allow-unauthenticated --quiet
Copied!
Boom! You have deployed the application container to Cloud Run.

Next steps

Cloud Run is worth looking into by teams. It provides affordability, security, isolation, and flexibility by allowing deployment to a Kubernetes cluster (Cloud Run for Anthos) and a lot more.
​This video demonstrates how fast it is to deploy and access containers with Cloud Run.
​This video demonstrates deploying directly to Cloud Run from your Git repository using the Cloud Run Button.
If you want to learn more about Cloud Run, check out the following resources:
Thanks for reading through! Let me know if I missed anything, if something didn’t work out quite right for you, or if this guide was helpful.
Last modified 6mo ago