Deploy Simple Java Application to Cloud run GCP

wahyu eko hadi saputro
3 min readMar 25, 2024

Google Cloud Run is a serverless platform provided by Google Cloud Platform (GCP) that allows developers to deploy containerized applications without the need to worry about managing the underlying infrastructure. It is built on top of Kubernetes and utilizes the Knative open-source project to abstract away much of the complexity involved in managing containers.

Here are step by step to deploy on cloud run for simple rest API java application:

  1. Connect to github or other repositories to connect to source code.

Click setup with cloud build, then there is a prompt to connect to github, and just fill the needed information to connect to github.

2. Setup trigger to trigger a build and deploy source code to cloud run

The trigger is upon push to a branch

Explanation of trigger detail:

Branch name : main branch

Configuration : cloud build configuration file (.yaml)

Location Inline: means the cloudbuild config is inline instead of put directly on source code

# Trigger based on source code changes
trigger:
- directory: # Path to your source code directory ()
branches: [ main ] # Monitor changes in the main branch
# Build configuration
builds:
- # Single build step using a Docker image
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/my-app:latest', '.']
# Specify the region (replace $PROJECT_ID with your actual ID)
regions: ['region-us'] # Deploy to Southeast Asia 2
# Optional: Notifications on build completion (uncomment to enable)
# notifications:
# email: your_email@example.com

3. Deployment configuration

--

--