Google Cloud Deployment

Deploy a production-ready Temp-Number App to Google Cloud Platform with automatic scaling, managed database, and SSL certificates.

Overview

Google Cloud deployment provides:

  • βœ… Auto-scaling: Automatically scales based on traffic
  • βœ… Managed Infrastructure: No server management required
  • βœ… Global CDN: Fast content delivery worldwide
  • βœ… Automatic SSL: Free HTTPS certificates
  • βœ… Automated Backups: Database backups included
  • βœ… High Availability: 99.95% uptime SLA

Architecture

Users

Cloud Run - Frontend

Cloud Run - Backend

Cloud SQL

Firebase Auth

Platfone API

Prerequisites

Required Accounts

  • Google Cloud: Account with billing enabled (Sign up )
  • Platfone: API credentials (Get access )
  • Domain Name: Custom domain (recommended)

Required Tools

  • gcloud CLI: Installation guide
  • Docker: For local image building (optional)
  • Git: For cloning the repository

Deployment

You can use the provided deployment scripts for automated deployment to Google Cloud. These scripts handle the entire deployment process, including building Docker images, deploying to Cloud Run, and configuring the necessary services.

git clone https://github.com/platfone-com/temp-number-deploy.git
cd temp-number-deploy
./google-cloud-deploy.sh

Script will prompt for necessary configuration values.

For automated assistance with Firebase and GCP setup, consider using the Setup Wizard instead.

Setup Wizard

Interactive setup wizard that handles all prerequisites and configuration

🐒 Manual Deployment Steps

Step 1: Clone the Deployment Repository

git clone https://github.com/platfone-com/temp-number-deploy.git
cd temp-number-deploy

Step 2: Clone Application Repositories

# Clone backend repository
git clone https://github.com/platfone-com/temp-number-backend.git
# Clone frontend repository
git clone https://github.com/platfone-com/temp-number-web.git

Step 3: Prepare environment

# Prepare environment variables
cp config/env/backend.env.example config/env/backend.env
cp config/env/web.env.example config/env/web.env
# Prepare secrets
cp config/secrets/backend.secrets.example config/secrets/backend.secrets
echo "Fill in the configuration files with your values"

Step 4: Prepare GCP and Firebase service accounts

  1. Create a Google Cloud service account with the following roles:

    • Cloud SQL Admin
    • Cloud Run Admin
    • Service Account User
    • Secret Manager Secret Accessor
    • Cloud Build Editor
    • Artifact Registry Administrator
    • Service Usage Admin
    • Logging Viewer
    • Storage Admin
    • IAM Service Account User
  2. Enable the following APIs in your Google Cloud project:

    • Cloud Build API
    • Cloud Run API
    • Cloud SQL Admin API
    • Secret Manager API
    • Artifact Registry API
    • Compute Engine API
    • Cloud Resource Manager API
    • IAM API
  3. Link your Google Cloud project to a billing account.

  4. Create a Firebase project

    1. Configure Firebase Authentication (Email/Password, Google, etc.)
    2. Generate a Firebase service account key and download the JSON file

    See Firebase Configuration Guide for detailed steps.

Step 5: Create Cloud SQL Instance

# Create Cloud SQL instance
./scripts/gcp/create_sql_instance.sh --project-id "YOUR_PROJECT_ID" --service-account "path_to_gcp-service-account.json" --env-file "path_to_backend.env" --secrets-file "path_to_backend.secrets" --region "us-central1" --db-tier "db-f1-micro" --service-name "temp-number-backend" --skip-if-exists

Step 6: Deploy Backend to Cloud Run

The following will:

  1. Create secrets in Secret Manager
  2. Grant access to Cloud Run service account
  3. Run Cloud Build to build and push Docker image
  4. Deploy the backend service to Cloud Run
  5. Run database migrations
./scripts/gcp/deploy_backend.sh --project-id "YOUR_PROJECT_ID" --service-account "path_to_gcp-service-account.json" --env-file "path_to_backend.env" --project-root "path_to_temp-number-backend" --region "us-central1" --service-name "temp-number-backend" --port 3333 --run-migrations --non-interactive

On successful deployment, note:

  1. the backend URL for frontend configuration.
  2. Payment gateway webhook URL (for Stripe, etc.).

Step 7: Deploy Web (Frontend) to Cloud Run

./scripts/gcp/deploy_web.sh --project-id "YOUR_PROJECT_ID" --service-account "path_to_gcp-service-account.json"  --env-file "path_to_web.env" --project-root "path_to_temp-number-web" --region "us-central1" --service-name "temp-number-web" --port 80

Note the frontend URL for DNS configuration.

Step 8: Update WEB Environment Variables

Update the following variables in your web.env file:

VITE_TEMP_NUMBER_FRONTEND_BASE_APP_URL=https://your-frontend-url
VITE_TEMP_NUMBER_BACKEND_API_BASE_PATH=https://your-backend-url

# Firebase console -> Settings -> General -> Your apps -> SDK setup and configuration
VITE_FIREBASE_WEB_API_KEY=YOUR_FIREBASE_WEB_API_KEY
VITE_FIREBASE_AUTH_DOMAIN=YOUR_FIREBASE_AUTH_DOMAIN
VITE_FIREBASE_PROJECT_ID=YOUR_PROJECT_ID
VITE_FIREBASE_APP_ID=YOUR_FIREBASE_APP_ID

Redeploy the web service after updating (see Step 6).

Step 9: Update Firebase Authentication Settings

  1. Update the Authorized Domains in Firebase Authentication settings to include your frontend domain.
  2. Set %LINK% variable in Firebase Authentication -> Templates -> Email address verification to <your frontend URL>/app/deeplink.

See Firebase Configuration Guide for detailed steps.

Next Steps

Configuration

Configure authentication and payments

Development Guide

Customize and extend the application