Arcade Re-Trail: Vaults & Vectors | Deploy Your Website on Cloud Run

Solution for Arcade Re-Trail: Vaults & Vectors | Deploy Your Website on Cloud Run. 1 lab: GSP659. Fast copy-paste commands for Google Cloud.

GSP659 — Deploy Your Website on Cloud Run

Estimated time: 20 minutes

# 🚀 Deploy your Website on Cloud Run > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created for educational purposes, hands-on practice, and Google Cloud certification preparation. This guide is designed to help learners understand containerized application deployment, Cloud Run, Artifact Registry, Cloud Build, Node.js, React, concurrency configuration, and zero-downtime application updates. Always attempt the lab yourself first and follow Google Cloud Skills Boost / Q

# ==============================================================================
# ORBIT OF OPS - GSP659 (COMMAND 1 OF 2: V1.0.0 DEPLOYMENT)
# ==============================================================================
GREEN='\e[1;32m'
CYAN='\e[1;36m'
YELLOW='\e[1;33m'
BLUE='\e[1;34m'
MAGENTA='\e[1;35m'
RED='\e[1;31m'
RESET='\e[0m'
BOLD='\e[1m'

clear
echo -e "${CYAN}${BOLD}"
cat << "EOF"
  ____       _     _ _            __    ___            
 / __ \     | |   (_) |          / _|  / _ \           
| |  | |_ __| |__  _| |_   ___  | |_  | | | |_ __  ___ 
| |  | | '__| '_ \| | __| / _ \ |  _| | | | | '_ \/ __|
| |__| | |  | |_) | | |_ | (_) || |   | |_| | |_) \__ \
 \____/|_|  |_.__/|_|\__| \___/ |_|    \___/| .__/|___/
                                            | |        
                                            |_|        
EOF
echo -e "${RESET}"
echo -e "${MAGENTA}${BOLD}>>> ORBIT OF OPS: GSP659 INITIATED <<<${RESET}\n"

echo -e "${BOLD}${YELLOW}[Orbit of Ops] Auto-fetching Project and Region...${RESET}"
export PROJECT_ID=$(gcloud config get-value project 2>/dev/null)
export REGION=$(gcloud compute project-info describe --format="value(commonInstanceMetadata.items[google-compute-default-region])" 2>/dev/null | tail -n 1)

if [[ -z "$REGION" ]]; then
    read -p "$(echo -e "${BOLD}${CYAN}Please enter the lab Region (e.g., us-central1): ${RESET}") " REGION
    export REGION
fi

gcloud config set compute/region $REGION --quiet
echo -e "✅ Project ID: ${GREEN}$PROJECT_ID${RESET}"
echo -e "✅ Region:     ${GREEN}$REGION${RESET}\n"

echo -e "${BLUE}${BOLD}[Orbit of Ops] Enabling Required APIs...${RESET}"
gcloud services enable artifactregistry.googleapis.com cloudbuild.googleapis.com run.googleapis.com --quiet

echo -e "${CYAN}${BOLD}[Orbit of Ops] Creating Artifact Registry & Configuring Docker...${RESET}"
gcloud artifacts repositories create monolith-demo --repository-format=docker --location=$REGION --description="Awesome Lab" --quiet 2>/dev/null || true
gcloud auth configure-docker ${REGION}-docker.pkg.dev --quiet

echo -e "${MAGENTA}${BOLD}[Orbit of Ops] Cloning Repo & Installing Dependencies (Takes ~1 min)...${RESET}"
cd ~
rm -rf monolith-to-microservices
git clone https://github.com/googlecodelabs/monolith-to-microservices.git --quiet
cd ~/monolith-to-microservices
./setup.sh

echo -e "${YELLOW}${BOLD}[Orbit of Ops] Building v1.0.0 Docker Image in Cloud Build (Takes ~2 mins)...${RESET}"
cd ~/monolith-to-microservices/monolith
gcloud builds submit --tag ${REGION}-docker.pkg.dev/${PROJECT_ID}/monolith-demo/monolith:1.0.0 --quiet

echo -e "${BLUE}${BOLD}[Orbit of Ops] Deploying v1.0.0 to Cloud Run...${RESET}"
gcloud run deploy monolith \
    --image ${REGION}-docker.pkg.dev/${PROJECT_ID}/monolith-demo/monolith:1.0.0 \
    --region $REGION \
    --allow-unauthenticated \
    --quiet

echo -e "${CYAN}${BOLD}[Orbit of Ops] Modifying Concurrency to 1, then reverting to 80...${RESET}"
gcloud run deploy monolith --image ${REGION}-docker.pkg.dev/${PROJECT_ID}/monolith-demo/monolith:1.0.0 --region $REGION --concurrency 1 --quiet
gcloud run deploy monolith --image ${REGION}-docker.pkg.dev/${PROJECT_ID}/monolith-demo/monolith:1.0.0 --region $REGION --concurrency 80 --quiet

echo -e "\n${GREEN}${BOLD}🎉 COMMAND 1 COMPLETE!${RESET}"
echo -e "${YELLOW}${BOLD}You can now safely click 'Check my progress' for Tasks 2, 3, and 4! Then proceed to Command 2.${RESET}"
# ==============================================================================
# ORBIT OF OPS - GSP659 (COMMAND 2 OF 2: V2.0.0 DEPLOYMENT)
# ==============================================================================

echo -e "${MAGENTA}${BOLD}[Orbit of Ops] Applying Website Updates...${RESET}"
cd ~/monolith-to-microservices/react-app/src/pages/Home
mv index.js.new index.js

echo -e "${BLUE}${BOLD}[Orbit of Ops] Building updated React App...${RESET}"
cd ~/monolith-to-microservices/react-app
npm run build:monolith --silent

echo -e "${YELLOW}${BOLD}[Orbit of Ops] Building v2.0.0 Docker Image in Cloud Build (Takes ~2 mins)...${RESET}"
cd ~/monolith-to-microservices/monolith
gcloud builds submit --tag ${REGION}-docker.pkg.dev/${PROJECT_ID}/monolith-demo/monolith:2.0.0 --quiet

echo -e "${CYAN}${BOLD}[Orbit of Ops] Deploying v2.0.0 to Cloud Run (Zero Downtime Update)...${RESET}"
gcloud run deploy monolith \
    --image ${REGION}-docker.pkg.dev/${PROJECT_ID}/monolith-demo/monolith:2.0.0 \
    --region $REGION \
    --allow-unauthenticated \
    --quiet

echo -e "\n${GREEN}${BOLD}🎉 COMMAND 2 COMPLETE!${RESET}"
echo -e "${MAGENTA}${BOLD}The zero-downtime update is live. Click 'Check my progress' for Tasks 5 and 6!${RESET}"