Your organization is establishing a deployment pipeline for a stateless containerized web application using Google Cloud Run in the us-central1 region. The application source code is stored locally and needs to be built into a container image, stored in a managed repository, and deployed to Cloud Run with public unauthenticated access enabled. What is the correct sequence of execution steps to deploy this serverless application using the Google Cloud CLI from start to finish?
- 1Enable the Cloud Run API (`run.googleapis.com`) and Artifact Registry API (`artifactregistry.googleapis.com`) in your Google Cloud project using `gcloud services enable`.
- 2Create a Docker repository in Artifact Registry in the `us-central1` region using `gcloud artifacts repositories create`.
- 3Submit the local source code to Cloud Build to compile and push the container image to Artifact Registry using `gcloud builds submit --tag us-central1-docker.pkg.dev/PROJECT_ID/my-repo/my-app:v1`.
- 4Deploy the container image to Cloud Run and configure public access using `gcloud run deploy my-service --image us-central1-docker.pkg.dev/PROJECT_ID/my-repo/my-app:v1 --region us-central1 --allow-unauthenticated`.
Answer
The correct sequence of steps begins with enabling the Cloud Run and Artifact Registry APIs, followed by creating the Artifact Registry Docker repository, then submitting the source code to Cloud Build to build and push the container image, and finally deploying the container image from Artifact Registry to Cloud Run using gcloud run deploy with the --allow-unauthenticated flag.
The deployment of a serverless Cloud Run application follows a strict dependency order: API enablement allows resource management, creating the Artifact Registry repository provides the storage destination, compiling source code via Cloud Build pushes the container image to that repository, and finally running gcloud run deploy references the stored image to deploy the running service.
Step-by-Step Solution
Key Concept
Serverless Container Deployment Workflow with Cloud Run and Artifact Registry