Managed serverless computing with Cloud Run

3 min read 2 hours ago
Published on Oct 13, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial guides you through the process of utilizing managed serverless computing with Google Cloud Run. Cloud Run allows you to run containerized applications without worrying about the underlying infrastructure. This tutorial is relevant for developers looking to deploy applications quickly and efficiently in a serverless environment.

Step 1: Set Up Your Google Cloud Project

  • Create a Google Cloud account if you don't already have one.
  • Create a new project:
    • Go to the Google Cloud Console.
    • Click on the project drop-down menu and select "New Project."
    • Enter a name for your project and click "Create."
  • Enable billing for your project if required.

Step 2: Enable Cloud Run API

  • Navigate to the "APIs & Services" dashboard in the Google Cloud Console.
  • Click on "Enable APIs and Services."
  • Search for "Cloud Run API" and click on it.
  • Click the "Enable" button to activate the Cloud Run API for your project.

Step 3: Install Google Cloud SDK

  • Download and install the Google Cloud SDK from the official website.
  • After installation, open your command line interface and run:
    gcloud init
    
  • Follow the prompts to log in and select your project.

Step 4: Build Your Container Image

  • Create a Dockerfile in your project directory. A basic example is:
    # Use an official Node.js runtime as a parent image
    FROM node:14
    # Set the working directory in the container
    WORKDIR /usr/src/app
    # Copy package.json and install dependencies
    COPY package*.json ./
    RUN npm install
    # Copy the rest of the application code
    COPY . .
    # Expose the application port
    EXPOSE 8080
    # Command to run the application
    CMD ["node", "app.js"]
    
  • Build the container image:
    gcloud builds submit --tag gcr.io/[PROJECT_ID]/[IMAGE_NAME]
    
    Replace [PROJECT_ID] and [IMAGE_NAME] with your actual project ID and desired image name.

Step 5: Deploy Your Application to Cloud Run

  • Use the following command to deploy your application:
    gcloud run deploy [SERVICE_NAME] --image gcr.io/[PROJECT_ID]/[IMAGE_NAME] --platform managed
    
    Replace [SERVICE_NAME] with your chosen service name.
  • Select the region where you want to deploy your service when prompted.
  • Allow unauthenticated invocations if you want it to be publicly accessible.

Step 6: Access Your Deployed Service

  • After deployment, you will receive a URL for your service.
  • Open the URL in your web browser to access your application.

Conclusion

In this tutorial, you learned how to set up a Google Cloud project, enable the Cloud Run API, install the Google Cloud SDK, build and deploy a containerized application, and access your deployed service. These steps will help you leverage serverless computing effectively. As next steps, consider exploring additional Cloud Run features, such as configuring custom domains or setting up CI/CD pipelines for automated deployments.