10 min read

GCP Deployment

Deploy your VibeReady application to Google Cloud Platform using Terraform for infrastructure provisioning, Cloud Run for serverless hosting, and GitHub Actions for CI/CD.


Prerequisites

Before starting, ensure you have the following installed and configured:

  • gcloud CLI
  • GitHub CLI
  • A GCP billing account with appropriate permissions
  • A GitHub repository for your project

1. Authenticate

Log in to both Google Cloud and GitHub:

# Login to Google Cloud
gcloud auth login
gcloud auth application-default login

# Login to GitHub
gh auth login

2. Run Deployment Setup

make setup-deployment

This interactive wizard handles the following:

  • Creates a GCP project
  • Enables required APIs
  • Sets up Terraform infrastructure
  • Configures GitHub Actions secrets for CI/CD

3. Infrastructure Created

The setup provisions the following GCP resources:

ResourcePurpose
Cloud RunServerless app hosting with automatic scaling
Cloud SQLManaged PostgreSQL database
Artifact RegistryDocker image storage
Secret ManagerSecure storage for API keys and credentials
Workload IdentitySecure, keyless authentication for GitHub Actions

4. Deploy

Pushing to the main branch triggers an automatic deployment through GitHub Actions:

git add .
git commit -m "Deploy to GCP"
git push origin main

Monitor deployment progress in your GitHub repository under the Actions tab.


5. Get App URL

After deployment, retrieve your application URL:

gcloud run services list --format='value(status.url)'

You can also find the URL in the GitHub Actions deployment logs.


6. Custom Domain (Optional)

By default, NEXT_PUBLIC_APP_URL is auto-configured to the Cloud Run URL after each deployment.

To use a custom domain:

  1. Map your domain in the GCP Console: navigate to Cloud Run, select your service, then Manage Custom Domains.
  2. Set a GitHub variable to override the auto-detected URL:
gh variable set NEXT_PUBLIC_APP_URL --body "https://app.yourdomain.com"
  1. The next deployment will use your custom domain.

Manual Terraform Commands

If you need to manage infrastructure manually, navigate to your Terraform environment directory and run standard Terraform commands:

# Initialize Terraform
terraform init

# Preview changes
terraform plan

# Apply changes
terraform apply

# Destroy infrastructure (use with caution)
terraform destroy

Troubleshooting

IssueSolution
”Billing not enabled”Link a billing account in the GCP Console.
”Permission denied”Verify IAM roles. Owner or Editor access is required.
”Quota exceeded”Request a quota increase in the GCP Console.
Terraform state lockRun terraform force-unlock <LOCK_ID> to release the lock.
Auth expiredRe-run gcloud auth application-default login.

Cost Optimization

The default configuration uses a scale-to-zero approach to minimize costs:

  • Cloud Run: 0 minimum instances. You pay only when requests are being processed.
  • Cloud SQL: db-f1-micro tier, approximately $7/month.
  • Storage: Pay-per-use pricing.

Estimated cost for low-traffic applications is approximately $10-20/month.


Starting Over

If you need to tear down your infrastructure and start fresh:

make setup-cleanup

Choose Infrastructure only to delete GCP resources while preserving local files, or Everything for a complete reset.


Environment Variables

Sensitive environment variables are managed through GCP Secret Manager. To update them:

  1. Update values in your Terraform configuration file.
  2. Run terraform apply to push changes to Secret Manager.

Alternatively, you can update secrets directly in the GCP Console under Secret Manager.


Ready to build with VibeReady?

Get the full AI-native SaaS foundation with production infrastructure, AI development framework, and all integrations.

Get VibeReady — From $149