Quickstart: Deploying a Cloud Run app with Cloud Code

This page shows you how to get started with Cloud Code.

You'll set up a Hello World application that runs on Cloud Run using a starter template, deploy your app to Cloud Run, and view the status of your live application's resources.

Creating a new Cloud Run app with Cloud Code

Before you begin

To use Cloud Run, you'll create a GCP project and enable billing.

Additionally, you'll need to enable Cloud Run support on your project. In the Console, use the navigation menu to access APIs and Services > Dashboard. Click on 'Cloud Run API' within the list of available APIs and click Enable API.

Installing Cloud Code

To install the Cloud Code plugin:

  1. Install JetBrains IDE version 2019.3+ (such as IntelliJ Ultimate/Community, PyCharm Professional/Community, WebStorm, GoLand), if you haven't already.
  2. Install dependencies:
    • For all Cloud platforms, ensure the Docker client (authenticated with your Docker registry) is installed on the PATH of your machine. (Its respective folder should be visible under a directory within your PATH.) To check if you already have Docker installed, run docker -v.
    • Cloud Code automatically installs other necessary dependencies.
  3. Open IntelliJ IDEA (or any supported JetBrains IDE).
  4. From your plugins marketplace (File > Settings > Plugins or for Mac OS X, IntelliJ IDEA > Preferences > Plugins), search for the 'Cloud Code' plugin and install it. You may be prompted to restart your IDE to activate the plugin.

Creating an application

To create a new application using an existing sample:

  1. In your IDE, open File > New Project and select Cloud Code: Cloud Run.
  2. Select a 'Hello World' template from the list of starter applications. Creating an app from a list of existing sample apps
  3. Pick a name for your project.

    Once you click Finish, Cloud Code will clone your chosen template, open your newly created project for use, and create necessary Cloud Run run configurations.

    • For Java templates, you'll be prompted to import Maven projects to sync your pom.xml. Click 'Add as Maven project'.

      Non-managed pom.xml notification

      Additionally, import necessary Maven projects by clicking 'Import Changes'.

      Import Maven changes notification

Deploying your app to Cloud Run

To deploy your application, follow these steps:

  1. Choose the automatically created run configuration, Cloud Run: Deploy, from the Run/Debug configurations dialog on the top taskbar.
  2. Click 'Run' run action icon. This brings up the 'Edit configuration' window.
  3. Set your Google Cloud project ID.
  4. Choose a region for your deployment platform. This quickstart uses the default platform option, 'Cloud Run (fully managed)', as the 'Deployment Platform'.
  5. Click 'Run'.
  6. View your running app by following the URL displayed in the output window.
  7. You can also view the status of your application (metrics, revision details, and more) by following the logs URL displayed in the output window.

    Viewing the status of your app in the Console

Viewing resource status

To view the status of your running application's resources, follow these steps:

  1. Navigate to the Cloud Run Explorer. It can be accessed from the side panel on the right.

    Cloud Run explorer tab highlighted on the right hand-side panel

  2. Click on a service or a revision in the explorer to display its properties.

    Cloud Run explorer open with a service selected and its properties displayed below

  3. Right-click a revision to view its logs.

    Right-click on a revision to view its logs

Cleaning up

If you created a project for this quickstart, be sure to delete it to avoid unnecessary charges:

  • Go to the Projects page in the Cloud Console:

    Go to the Projects page

  • Select the project you created for this Quickstart and click on the trash can icon next to delete it.

    This shuts down the project and schedules it for deletion.

If you're using a pre-existing project and would like to delete resources you created for this quickstart:

  • Container image: While Cloud Run does not charge when the service is not in use, you might still be charged for storing the container image in Container Registry. To delete your image, follow this guide.
  • Cloud Run service: To delete a Cloud Run service, navigate to Cloud Run in the Console using the navigation menu. Select the service you'd like to delete and click on the 'Delete' trash can icon.

What's next

Getting Support

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