Deploy services on Google Cloud Run

Shubhangi Thakur
3 min readJul 5, 2023

--

In this blog, I will guide you on how to create service in Cloud Run on the Google Cloud platefrom. I will provide a detailed, step-by-step demonstration of how to service by deploying a sample application to the Google Cloud Run.

What is Cloud Run ?

Cloud Run is a serverless compute platform provided by Google Cloud Platform (GCP). It allows developers to deploy and run applications in containers without the need to manage underlying infrastructure. Cloud Run abstracts away the server and operating system management, enabling developers to focus on building and deploying their applications.

Cloud Run supports applications packaged in Docker containers, making it compatible with a wide range of programming languages and frameworks. You can build your application using any language or framework of your choice, containerize it using Docker, and then deploy it to Cloud Run.

What is Services in cloud run ?

In Cloud Run, a service refers to a specific instance of a deployed application or containerized workload. It represents a single version of your application that is running and accessible on the Cloud Run platform.

When you deploy an application to Cloud Run, you create a service. Each service has its own unique URL endpoint that can be used to access the application. The URL follows the format: https://<service-url>.run.app.

Services in Cloud Run are designed to be scalable and stateless. This means that they can automatically scale up or down based on incoming request traffic. When there is a surge in traffic, Cloud Run will spin up additional containers to handle the increased load, and when the traffic decreases, it can scale down the number of containers.

Let’s see..

To deploy an application on Cloud Run, you need to create a Docker image of your application and then deploy that image to Cloud Run.

Setp-1. I will create sample docker image using Dockerfile.

This is sample application:

Dockerfile:

FROM nginx:latest
COPY html-sample-app /usr/share/nginx/html
EXPOSE 8080

Now build this image using this command:

docker build -t <give image name> .

Step-2. Upload created image to Artifact registry:

gcloud auth login
docker tag <give image name> us-central1-docker.pkg.dev/<project-id>/<repo-nmae>/<image-name>:latest
docker push us-central1-docker.pkg.dev/<project-id>/<repo-nmae>/<image-name>:latest

Step-3. Go to Cloud Run

You can consider the below configuration or create your own according to your use case and then click on done.

  • Click to create service
  • Now click on select then left dialog box will open and select your image in drop-down list and click on select
  • Allow unauthenticated invocations
  • Give container port 80
  • Click on create

Step-4. Service successfully deployed on cloud run

  • Using this url you can access your application

Thanks for reading this, hope it helped you in some way. Happy Deploying on Google Cloud.

Read: Google Cloud Run Jobs for background tasks.

--

--

Shubhangi Thakur

Hi, I am Student | Cloud Engineer | GCP+AWS Cloud | DevOps | 2XGCP Certified