Developing a service locally

With Cloud Code, you can develop your Cloud Run services locally in a Cloud Run-like environment. Cloud Code watches for changes in your source and quickly updates the running service to reflect these changes.

Defining your run configuration

Before you run 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 Cloud Run: Run Locally under Cloud Code: Cloud Run.
  3. Specify your builder option and its relevant settings.

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

  4. Click OK.

    Cloud Run: Run locally configuration window

Optional: Customizing your configuration

When developing locally, you can specify additional settings like a service account, environment variables, and SQL connections (when using Cloud Run (fully managed)), using 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

Storing secrets

If your code includes potentially sensitive data like API keys, passwords, and certificates, it is recommended you store them as secrets. With Cloud Code, you can securely store these secrets in Secret Manager and programmatically fetch them when you need them. For a detailed look at how you can create and manage secrets with Cloud Code, refer to the Secret Manager guide.

Running your service

To run your service, follow these steps:

  1. Choose the Cloud Run: Run Locally run target from the Run/Debug configurations selector in the Navigation bar.
  2. Click Cloud Run: Run Locally run action icon.
  3. View the logs from your running service, streamed directly to the output window.
  4. Once deployment is complete, you can view your running service by following the URL displayed in your Event Log panel. In the example below, this URL is http://localhost:8080.

    Event log with successful deployment notification and URL to preview your service

Getting support

To submit feedback or report an issue in your IntelliJ IDE, go to Tools > Cloud Code > Help / About > Submit feedback or report an issue to report an issue on GitHub, or ask a question on Stack Overflow.

You can also join the #cloud-code channel, which is part of the Google Cloud Slack community.