Deploying a service to Cloud Run

Now that you're all set up, you can deploy your service to Cloud Run and view your service live.

Defining your run configuration

Before you deploy your service, you must create your run configuration:

  1. Navigate to Run/Debug configurations selector in the Navigation bar and click Edit Configurations.
  2. Choose your Cloud Code: Cloud Run run configuration (or add a new one).
  3. Set your Google Cloud project ID.
  4. Choose your platform preferences under Deployment Platform, either Cloud Run (fully managed) or Cloud Run for Anthos. For a detailed description of each option, see the Cloud Run platform guide.

    • If Cloud Run (fully managed) is selected, choose a region to deploy to.
    • If Cloud Run for Anthos is selected, configure the Kubernetes cluster information.

      Deployment platform options: Fully Managed (chosen) and Anthos on GKE with a region specified

  5. If your service is a public API or website, choose Allow unauthenticated invocations in the Authentication section. Otherwise, select Require authentication.

  6. Under Revision Settings, Cloud Code automatically populates the container image URL field with the storage location of your container image (where it stores your service, once it builds and containerizes it). This value is based on your Google Cloud project and service name.

    If you need to, you can override this value:

    • For both Cloud Run (fully managed) and Cloud Run for Anthos, you can store your images on Container Registry and use the following format: gcr.io/{project-name}/{image-name}, where {project-name} is the name of your GCP project and {image-name} refers to the container image repository.
    • If you're using Cloud Run for Anthos, you can store your images on Docker Hub and use the following format: docker.io/{account} where {account} is the name of your Docker Hub account. Make sure that you're properly authenticated if you're using a private Docker Hub repository.

      Run/Debug configuration open with sample fields (project ID and region) filled in

  7. Under Build settings, choose whether to build locally or on Cloud Build.

    If you're developing on Apple M-series silicon, selecting the Cloud Build option ensures that you're building an image that can run on Cloud Run's x86 architecture. For information about the cost of building your application using Cloud Build, see Cloud Build Pricing.

  8. Choose a builder and plugin.

    Cloud Code supports Docker, Jib, and Buildpacks artifact types.

  9. Click OK.

Optional: Customizing your configuration

When deploying your service, you can specify additional settings such as a service account, environment variables, and, when using Cloud Run (fully managed), a VPC Connector and SQL connections. Specify the additional settings in the Advanced revision settings section when you choose Edit Configurations.

Environment variables:

The following environment variables are automatically added to the running containers:

Name Description Example
PORT The port your HTTP server should listen on. 8080
K_SERVICE The name of the Cloud Run service being run. hello-world
K_REVISION The name of the Cloud Run revision being run. hello-world.1
K_CONFIGURATION The name of the Cloud Run configuration that created the revision. hello-world

Deploying your service

To deploy your service, follow these steps:

  1. Choose your run target from the Run/Debug configurations dialog on the top taskbar.
  2. Click Run run action icon.
  3. View your running service by following the URL displayed in the output window.
  4. You can also view the status of your service (metrics, revision details, and more) by following the logs URL displayed in the output window.

    Viewing the status of your service in the Console

Getting support

To send feedback, report an issue on GitHub or ask a question on Stack Overflow.