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:
- Navigate to Run/Debug configurations dialog on the top taskbar and click 'Edit Configurations'.
- Choose your Cloud Code: Cloud Run run configuration (or add a new one).
- Set your Google Cloud project ID.
Choose your platform preferences under 'Deployment Platform', either 'Cloud Run (fully managed)' or 'Cloud Run for Anthos on GKE'. Refer to the Cloud Run platform guide for a detailed description of each option.
- If 'Fully Managed' is selected, choose a region to deploy to.
If 'Anthos on GKE' is selected, configure the Kubernetes cluster information.
Choose 'Allow unauthenticated invocations' for your authentication preferences, if your service is a public API or website. Otherwise, select 'Require authentication'.
Under 'Revision Settings', Cloud Code will automatically populate the container image URL field with the storage location of your container image (where it'll store 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 choose to override this value:
- For both Cloud Run (fully managed) and Cloud Run for Anthos, you can store your images on Google 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 choose to store your images on Docker Hub (ensure that you are properly authenticated if you are using a private Docker Hub repository), use the following format: docker.io/{account} where {account} is the name of your Docker Hub account.
Specify your builder option and its relevant settings.
Cloud Code supports Docker, Jib, and Buildpacks artifact types.
Click 'OK'.
Optional: Customizing your configuration
When deploying your service, you can also 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 |
Deploying your service
To deploy your service, follow these steps:
- Choose your run target from the Run/Debug configurations dialog on the top taskbar.
- Click 'Run'
.
- View your running service by following the URL displayed in the output window.
You can also view the status of your service (metrics, revision details, and more) by following the logs URL displayed in the output window.