Text of docs.cloud.google.com › run › docs › deploying-source-code as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Deploy services from source code | Cloud Run | Google Cloud Documentation

Skip to main content Console English Deutsch Español Español – América Latina Français Indonesia Italiano Português Português – Brasil עברית 中文 – 简体 中文 – 繁體 日本語 한국어 Sign in Cloud Run Start free Home Documentation Application hosting Cloud Run Guides Deploy services from source code Stay organized with collections Save and categorize content based on your preferences. This page describes how to deploy a new service or service revision to Cloud Run directly from source code using a single gcloud CLI command, gcloud run deploy with the --source flag.

For an example walkthrough of deploying a Hello World service, see Deploy from source quickstarts . There are two different ways to use this feature: Deploy from source with build (default): This option uses Google Cloud's buildpacks and Cloud Build to automatically build container images from your source code without having to install Docker on your machine or set up buildpacks or Cloud Build. By default, Cloud Run uses the default machine type provided by Cloud Build .

Running gcloud run deploy --source also eliminates the need to run the gcloud builds submit command. Deploy prebuilt source (Preview): This option deploys artifacts directly to Cloud Run, bypassing the Cloud Build step. This allows for rapid deployment times. Note that source deployments use Artifact Registry to store built containers. If your project doesn't already have an Artifact Registry repository with the name cloud-run-source-deploy in the region you are deploying to, this feature automatically creates an Artifact Registry repository with the name cloud-run-source-deploy .

If a Dockerfile is present in the source code directory, the uploaded source code is built using that Dockerfile. If no Dockerfile is present in the source code directory, Google Cloud's buildpacks automatically detects the language you are using and fetches the dependencies of the code to make a production-ready container image, using a secure base image managed by Google. By default, security fixes are only applied when the Cloud Run service is deployed.

When you enable automatic security updates for a service, that service receives patches automatically with zero downtime. Learn more about configuring security updates . Before you begin Make sure you have set up a new project for Cloud Run as described in the setup page. If you are under a domain restriction organization policy restricting unauthenticated invocations for your project, you will need to access your deployed service as described under Testing private services .

Enable the Cloud Run Admin API, if it is not already enabled. Roles required to enable APIs To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role ( roles/owner ). Otherwise, you can get this permission through the Service Usage Admin role ( roles/serviceusage.serviceUsageAdmin ). Learn how to grant roles . Enable the API After the Cloud Run Admin API is enabled, the Compute Engine default service account is automatically created.

Required roles To deploy from source, you or your administrator must grant the deployer account the following IAM roles. Click to view required roles for the deployer account To get the permissions that you need to build and deploy from source, ask your administrator to grant you the following IAM roles: Cloud Run Source Developer ( roles/run.sourceDeveloper ) on your project Service Usage Consumer ( roles/serviceusage.serviceUsageConsumer ) on your project Service Account User ( roles/iam.serviceAccountUser ) on the Cloud Run service identity For a list of IAM roles and permissions that are associated with Cloud Run, see Cloud Run IAM roles and Cloud Run IAM permissions .

If your Cloud Run service interfaces with Google Cloud APIs, such as Cloud Client Libraries, see the service identity configuration guide . For more information about granting roles, see deployment permissions and manage access . Supported languages In addition to sources with a Dockerfile, deploying from source supports the following languages using Google Cloud's buildpacks : Runtime Source deployment Configuration Go Deploy a Go service Configure Go buildpacks Node.js Deploy a Node.js service Configure Node.js buildpacks Python Deploy a Python service Configure Python buildpacks Java (includes Kotlin, Groovy, Scala) Deploy a Java service Configure Java buildpacks .NET Deploy a .NET service Configure .NET buildpacks Ruby Deploy a Ruby service Configure Ruby buildpacks PHP Deploy a PHP service Configure PHP buildpacks OS only Deploy a Go or Dart service Configure OS only runtime Read more details about supported language versions .

Deploy from source with build This section describes how to use Google Cloud's buildpacks and Cloud Build to automatically build container images from your source code without having to install Docker on your machine or set up buildpacks or Cloud Build. Limitations Deploy from source uses Artifact Registry and Cloud Build, so this feature is only available in regions supported by Artifact Registry and Cloud Build . Deploying from source is a convenience feature, and does not allow full customization of the build.

For more control, build the container image using Cloud Build, for example, using gcloud builds submit , and then deploy the container image using, for example, gcloud run deploy --image . Deploying from source with Google Cloud's buildpacks sets the Last Modified Date of source files to Jan 1, 1980. This is the default behavior of buildpacks and is designed to support reproducible builds . Depending on your language framework, this can affect browser-side caching of static files.

If your application is affected by this, Google recommends disabling etag and Last-Modified HTTP headers in your application. Deploying from source with Google Cloud's buildpacks always uses gcr.io/buildpacks/builder:latest . If your preferred language or OS configuration is not available in latest , use a specific builder to create an application image using your preferred builder. You can deploy your service from source using Kotlin and other JVM languages such as Java .

The language you use must conform to the following rules: You can build the application using Maven or Gradle. The build file contains all the plugins required to produce classes. Before you deploy with build Before you deploy from source with build: Follow the steps in Before you begin . Enable the Cloud Build API, if it is not already enabled. Roles required to enable APIs To enable APIs, you need the serviceusage.services.enable permission.

If you created the project, then you likely already have this permission through the Owner role ( roles/owner ). Otherwise, you can get this permission through the Service Usage Admin role ( roles/serviceusage.serviceUsageAdmin ). Learn how to grant roles . Enable the API Required roles To deploy from source with build, you or your administrator must grant the Cloud Build service account the following IAM roles. Click to view required roles for the Cloud Build service account Cloud Build automatically uses the Compute Engine default service account as the default Cloud Build service account to build your source code and Cloud Run resource, unless you override this behavior.

For Cloud Build to build your sources, ask your administrator to grant Cloud Run Builder ( roles/run.builder ) to the Compute Engine default service account on your project: gcloud projects add-iam-policy-binding PROJECT_ID \ --member = serviceAccount: PROJECT_NUMBER -compute@developer.gserviceaccount.com \ --role = roles/run.builder Replace PROJECT_NUMBER with your Google Cloud project number, and PROJECT_ID with your Google Cloud project ID.

For detailed instructions on how to find your project ID, and project number, see Creating and managing projects . Granting the Cloud Run builder role to th

The rest of this page is on the live site.