Arcade Voyage: App Modernization | GSP328
Solution for Arcade Voyage: App Modernization | GSP328. 1 lab: GSP328. Fast copy-paste commands for Google Cloud.
GSP328 — Develop Serverless Applications on Cloud Run: Challenge Lab
Estimated time: 20 minutes
# 🚀 Develop Serverless Applications on Cloud Run: Challenge Lab > ⚠️ **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 Google Cloud services and complete practical exercises. Always attempt the lab yourself first and follow Google Cloud Skills Boost / Qwiklabs Terms of Service. This walkthrough is not affiliated with or endorsed by
clear
CYAN='\e[1;36m'
BLUE='\e[1;34m'
RESET='\e[0m'
BOLD='\e[1m'
GREEN='\e[1;32m'
YELLOW='\e[1;33m'
MAGENTA='\e[1;35m'
echo -e "${CYAN}${BOLD}"
cat << "EOF"
____ _ _ _ __ ___
/ __ \ | | (_) | / _| / _ \
| | | |_ __| |__ _| |_ ___ | |_ | | | |_ __ ___
| | | | '__| '_ \| | __| / _ \ | _|| | | | '_ \/ __|
| |__| | | | |_) | | |_ | (_) | | | | |_| | |_) \__ \
\____/|_| |_.__/|_|\__| \___/ |_| \___/| .__/|___/
| |
|_|
EOF
echo -e "${RESET}"
echo -e "${BLUE}${BOLD}╔════════════════════════════════════════════════════════════╗${RESET}"
echo -e "${BLUE}${BOLD}║ 🚀 BROUGHT TO YOU BY ORBIT OF OPS ║${RESET}"
echo -e "${BLUE}${BOLD}╚════════════════════════════════════════════════════════════╝${RESET}\n"
echo -e "${YELLOW}${BOLD}⚠️ IMPORTANT: Copy the EXACT names from your lab instruction tables!${RESET}"
read -p "Enter your Region (e.g., us-west1): " REGION
read -p "Enter your Task 1 Public Billing Service Name: " PUBLIC_BILLING_SERVICE
read -p "Enter your Task 2 Frontend Staging Service Name: " FRONTEND_STAGING_SERVICE
read -p "Enter your Task 3 Private Billing Service Name: " PRIVATE_BILLING_SERVICE
echo ""
export PROJECT_ID=$(gcloud config get-value core/project 2>/dev/null)
gcloud config set run/region "${REGION}" --quiet >/dev/null 2>&1
gcloud config set run/platform managed --quiet >/dev/null 2>&1
gcloud services enable run.googleapis.com cloudbuild.googleapis.com --quiet
echo -e "${CYAN}Cloning Pet Theory Repository...${RESET}"
cd ~
rm -rf pet-theory
git clone https://github.com/rosera/pet-theory.git >/dev/null 2>&1
echo -e "${CYAN}Task 1: Building & Deploying Public Billing Service...${RESET}"
cd ~/pet-theory/lab07/unit-api-billing
gcloud builds submit --tag "gcr.io/${PROJECT_ID}/billing-staging-api:0.1" --quiet
gcloud run deploy "${PUBLIC_BILLING_SERVICE}" --image "gcr.io/${PROJECT_ID}/billing-staging-api:0.1" --region "${REGION}" --allow-unauthenticated --quiet
echo -e "${CYAN}Task 2: Building & Deploying Frontend Staging Service...${RESET}"
cd ~/pet-theory/lab07/staging-frontend-billing
gcloud builds submit --tag "gcr.io/${PROJECT_ID}/frontend-staging:0.1" --quiet
gcloud run deploy "${FRONTEND_STAGING_SERVICE}" --image "gcr.io/${PROJECT_ID}/frontend-staging:0.1" --region "${REGION}" --allow-unauthenticated --quiet
echo -e "${CYAN}Task 3: Deleting Public API & Deploying Private Billing Service...${RESET}"
gcloud run services delete "${PUBLIC_BILLING_SERVICE}" --region "${REGION}" --quiet || true
cd ~/pet-theory/lab07/staging-api-billing
gcloud builds submit --tag "gcr.io/${PROJECT_ID}/billing-staging-api:0.2" --quiet
gcloud run deploy "${PRIVATE_BILLING_SERVICE}" --image "gcr.io/${PROJECT_ID}/billing-staging-api:0.2" --region "${REGION}" --no-allow-unauthenticated --quiet
echo -e "\n${GREEN}${BOLD}✅ Phase 1 Complete! Click 'Check my progress' on Tasks 1, 2, and 3, then proceed to Command 2.${RESET}"CYAN='\e[1;36m'
BLUE='\e[1;34m'
RESET='\e[0m'
BOLD='\e[1m'
GREEN='\e[1;32m'
YELLOW='\e[1;33m'
echo -e "${BLUE}${BOLD}╔════════════════════════════════════════════════════════════╗${RESET}"
echo -e "${BLUE}${BOLD}║ 🚀 COMMAND 2 OF 2: PRODUCTION DEPLOYMENT & IAM ║${RESET}"
echo -e "${BLUE}${BOLD}╚════════════════════════════════════════════════════════════╝${RESET}\n"
echo -e "${YELLOW}${BOLD}⚠️ IMPORTANT: Copy the EXACT names from your lab instruction tables!${RESET}"
read -p "Enter your Task 4 Billing Service Account Name: " BILLING_SA
read -p "Enter your Task 5 Billing Prod Service Name: " BILLING_PROD_SERVICE
read -p "Enter your Task 6 Frontend Service Account Name: " FRONTEND_SA
read -p "Enter your Task 7 Frontend Prod Service Name: " FRONTEND_PROD_SERVICE
echo ""
export PROJECT_ID=$(gcloud config get-value core/project 2>/dev/null)
export REGION=$(gcloud config get-value run/region 2>/dev/null)
echo -e "${CYAN}Task 4: Creating Billing Service Account...${RESET}"
gcloud iam service-accounts create "${BILLING_SA}" --display-name="Billing Service Cloud Run" --quiet || true
echo -e "${CYAN}Task 5: Building & Deploying Production Billing Service...${RESET}"
cd ~/pet-theory/lab07/prod-api-billing
gcloud builds submit --tag "gcr.io/${PROJECT_ID}/billing-prod-api:0.1" --quiet
gcloud run deploy "${BILLING_PROD_SERVICE}" --image "gcr.io/${PROJECT_ID}/billing-prod-api:0.1" --region "${REGION}" --service-account="${BILLING_SA}@${PROJECT_ID}.iam.gserviceaccount.com" --no-allow-unauthenticated --quiet
echo -e "${CYAN}Task 6: Creating Frontend Service Account & Applying IAM Bindings...${RESET}"
gcloud iam service-accounts create "${FRONTEND_SA}" --display-name="Billing Service Cloud Run Invoker" --quiet || true
gcloud run services add-iam-policy-binding "${BILLING_PROD_SERVICE}" --region "${REGION}" --member="serviceAccount:${FRONTEND_SA}@${PROJECT_ID}.iam.gserviceaccount.com" --role="roles/run.invoker" --quiet
echo -e "${CYAN}Task 7: Building & Deploying Production Frontend Service...${RESET}"
cd ~/pet-theory/lab07/prod-frontend-billing
gcloud builds submit --tag "gcr.io/${PROJECT_ID}/frontend-prod:0.1" --quiet
gcloud run deploy "${FRONTEND_PROD_SERVICE}" --image "gcr.io/${PROJECT_ID}/frontend-prod:0.1" --region "${REGION}" --service-account="${FRONTEND_SA}@${PROJECT_ID}.iam.gserviceaccount.com" --allow-unauthenticated --quiet
echo -e "\n${GREEN}${BOLD}🎉 AUTOMATION COMPLETE! Click 'Check my progress' on the remaining tasks to collect your 100% score!${RESET}"
echo -e "${GREEN}${BOLD}# ─────────────────────────────────────────────────────────────${RESET}"
echo -e "${GREEN}${BOLD}# Lab cleared? Like the video and subscribe to Orbit of Ops 🚀${RESET}"
echo -e "${GREEN}${BOLD}# youtube.com/@orbitofops${RESET}"
echo -e "${GREEN}${BOLD}# ─────────────────────────────────────────────────────────────${RESET}"