Cloud Deployment Guide
Once you have bootstrapped your application locally, the next major milestone is to build and deploy your containerized microservice directly to Google Cloud Platform (GCP).
The Milesoft CLI init app generator automatically scaffolds everything you need for production-grade deployments, packaging, and real-time operations.
💡 Note on Placeholders: Throughout this guide, you will see placeholders like
your-gcp-project-idandyour-app. In your actual scaffolded project folder, these are automatically replaced with your real Google Cloud Project ID and application name by themilesoft init appcommand during bootstrapping. If you need help finding your Project ID, refer to the How to Find Your GCP Project ID guide.
1. Scaffolded Infrastructure Manifests
Your generated project contains two core build definitions out-of-the-box:
1.1 cloudbuild.yaml
This Google Cloud Build configuration compiles your Spring Boot application inside a clean JDK container and publishes the resulting Docker image directly to your project's container registry:
steps:
- name: 'eclipse-temurin:21-jdk'
entrypoint: 'bash'
args:
- '-c'
- './gradlew bootJar --no-daemon'
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/your-app', '.' ]
images:
- 'gcr.io/$PROJECT_ID/your-app'
1.2 Dockerfile
A minimalist, high-performance container configuration that runs your compiled Spring Boot application using a secure, standard JDK 21 base image:
FROM eclipse-temurin:21-jdk
COPY build/libs/your-app.jar your-app.jar
EXPOSE 8080
CMD java -noverify -jar your-app.jar
2. Triggering the Deployment
Your generated project's root README.md contains the pre-configured deployment command customized with your actual application name and GCP project ID.
Option A: Click-to-Run via IntelliJ
- Open the project in IntelliJ IDEA.
- Open your project's root
README.md. - Locate the
gcloud run deploypipeline block. - Simply click the green "Play/Arrow" icon in the left gutter next to the command to execute it instantly in your IDE terminal!
Option B: Direct Terminal Deployment
Execute the combined compilation, remote build, and deployment script:
(Note: If copying from this central documentation guide, replace your-gcp-project-id and your-app with your actual values. If copying from your project's local bootstrapped README.md, these are already automatically replaced and pre-configured for you).
# Submit source files for remote container compilation
gcloud builds submit --project your-gcp-project-id && \
# Deploy the compiled image directly to Google Cloud Run
gcloud run deploy your-app \
--project your-gcp-project-id \
--image gcr.io/your-gcp-project-id/your-app:latest \
--region us-central1 \
--platform managed \
--allow-unauthenticated \
--memory 512Mi \
--cpu 1 \
--cpu-throttling \
--min-instances 1 \
--max-instances 5 \
--set-env-vars SPRING_PROFILES_ACTIVE=prod \
--timeout 600
Understanding the Deployment Parameters
The gcloud run deploy command includes pre-configured options designed to balance performance, cost, and security out-of-the-box:
| Option | Description |
|---|---|
your-app |
Positional argument. The identifier name for the Cloud Run service instance. |
--project |
The Google Cloud Project ID where the resource will be provisioned. |
--image |
The container image URL and tag (:latest) to run. |
--region |
The physical GCP region where the container runs (e.g., us-central1). |
--platform |
Targets managed to use Google's fully serverless, zero-maintenance compute platform. |
--allow-unauthenticated |
Grants public internet ingress access to your endpoints (critical for public APIs). |
--memory |
Allocates RAM resources to the running instance (e.g., 512Mi is standard for Spring Boot). |
--cpu |
Sets the CPU capacity limit allocated to the container (e.g., 1 virtual core). |
--cpu-throttling |
Limits container CPU resources when no requests are being processed, substantially lowering billing. |
--min-instances |
Sets a warm container baseline (e.g., 1) to prevent "cold start" latency for initial requests. |
--max-instances |
Limits auto-scaling threshold (e.g., 5) to prevent runaway costs during high-load spikes. |
--set-env-vars |
Configures key-value environment pairs (e.g., activating the Spring prod profile at runtime). |
--timeout |
Maximum duration (e.g., 600 seconds) a request is allowed to execute before being terminated. |
To further customize resource allocations, ingress networks, custom domains, or IAM security boundaries, explore the Official Google Cloud Run Deployment CLI Reference.
⏳ Performance Note: Google Cloud Build compiles and packages your Spring Boot application remotely inside Google's secure environment. This process typically takes between 2 to 5 minutes to complete.
3. Real-Time Operations (Log Tailing)
To monitor your live deployment and view real-time system outputs, execute the log-tailing script from your workspace (requires gcloud CLI tool authentication):
(Note: Replace your-app and your-gcp-project-id with your actual values, which are already pre-filled in your local workspace README.md).
gcloud beta run services logs tail your-app --project=your-gcp-project-id
4. Post-Deployment: Updating Base URLs
Upon successful deployment, the gcloud console prints your live endpoint:
Service URL: https://your-app-abc123-uw.a.run.app
Replacing the TBD Base URL
To utilize IntelliJ's native HTTP Client for integration tests, you must update your local environment profile settings:
- Open
http-client.env.jsonin your project root. - Locate the
"baseUrl"key currently set to"TBD". - Replace
"TBD"with your live Google Cloud Run Service URL:
{
"prod": {
"baseUrl": "https://your-app-abc123-uw.a.run.app"
}
}
5. Next Steps
With your microservice running live in the cloud and your base URLs updated, proceed to:
- Developer Keys & Personal Access Tokens (PAT) — Secure your live endpoints and acquire your first PAT to authorize API interactions.