Cloud Run deploys containerized applications as managed serverless services. It supports a provider-neutral application boundary, but deployment still requires deliberate choices about image storage, credentials, region, and authentication. section 6.4.4 section 6.4.3
A disciplined deployment keeps infrastructure changes separate from production code and makes risky defaults explicit:
- Build the application into a container image with a multi-stage Dockerfile using Maven and Java 17. section 6.4.4
- Push the image to Google Artifact Registry rather than the deprecated Container Registry. section 6.4.4
- Store API keys in Google Cloud Secret Manager instead of passing them through plain environment variables. section 6.4.4
- Configure the project, region, service name, provider, and access policy through explicit gcloud deployment commands. section 6.4.4
Deploying a provider-flexible service
A Java service is packaged into a container, uploaded to a regional Artifact Registry repository, and deployed to Cloud Run with the Gemini provider selected. The API key is exposed to the service through a named secret, while unauthenticated access is enabled for the demonstrated endpoint. Successful output confirms revision creation, traffic routing, and the service URL. section 6.4.4 section 6.4.3
Listing 6.23 Deploy application to Cloud Run
gcloud run deploy sql-generator-service \ --image europe-west1-docker.pkg.dev/aqueous-flames-478114-b5/[YOUR_REPO]/sql-generator-service \ --platform managed \ --region europe-west1 \ #A --allow-unauthenticated \ --set-env-vars=AI_PROVIDER=gemini \ --set-secrets=GOOGLE_AI_API_KEY=gemini-api-key:latest #B
Inspect the complete Cloud Run deployment command, including the managed platform, region, public access setting, provider variable, and secret binding. section 6.4.4

