Skip to content

dreamfactorysoftware/df-cloud-run

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DreamFactory on Google Cloud Run

Deploy DreamFactory with commercial features to Google Cloud Run.

Open in Cloud Shell

One-click deploy: Click the button above to open Google Cloud Shell with a guided deployment walkthrough. You'll need a GCP project with billing enabled and a DreamFactory license key.

Architecture

./deploy.sh
     │
     ▼
┌──────────────────────────────┐
│      Google Cloud Run        │
│  ┌─────────┐  ┌──────────┐  │
│  │  Nginx  │─▶│ PHP-FPM  │  │
│  │ :8080   │  │ (socket) │  │
│  └─────────┘  └──────────┘  │
└──────────┬───────────────────┘
           │ Cloud SQL Auth Proxy (sidecar)
  ┌────────▼──────────┐
  │    Cloud SQL       │
  │    MySQL 8.0       │
  └────────────────────┘

Two GCP resources: Cloud Run + Cloud SQL. Secrets in Secret Manager.

Prerequisites

  • Google Cloud account with billing enabled
  • gcloud CLI installed and authenticated (gcloud auth login)
  • DreamFactory license key (from your DreamFactory sales rep)
  • Commercial composer files (composer.json + composer.lock) — provided separately by DreamFactory via SFTP

Quick Start

  1. Add your commercial composer files (provided via SFTP) to this directory:
    composer.json
    composer.lock
    
  2. Run the deploy script:
    ./deploy.sh

The script will interactively prompt for:

  • GCP project ID
  • Region (default: us-central1)
  • DreamFactory license key
  • Admin email and password

That's it. The script provisions everything and gives you a URL.

Note: Without composer files, the script will build the open-source edition of DreamFactory. Commercial features (SAML, AD/LDAP, Oracle, etc.) require the commercial composer files.

Command Reference

deploy.sh

Flag Description Default
--build Build image from source Use pre-built image
--github-token=XXX GitHub token (required with --build)
--project=XXX GCP project ID Interactive prompt
--region=XXX GCP region us-central1
--service-name=XXX Cloud Run service name dreamfactory
--db-tier=XXX Cloud SQL machine tier db-g1-small
--yes Skip confirmation prompts

teardown.sh

Removes all resources created by deploy.sh. Confirms before each deletion.

./teardown.sh
./teardown.sh --project=my-proj --region=us-central1
./teardown.sh --yes  # Skip confirmations

Configuration

Environment Variables

Set via Cloud Run environment variables or --set-env-vars in deploy:

Variable Description Default
DB_CONNECTION Database driver mysql
DB_HOST Database host 127.0.0.1 (proxy)
DB_PORT Database port 3306
DB_DATABASE Database name dreamfactory
DB_USERNAME Database user dreamfactory
CACHE_DRIVER Cache backend database
SESSION_DRIVER Session backend database
APP_DEBUG Debug mode false
APP_LOG_LEVEL Log level warning
LOG_CHANNEL Log output stderr
ADMIN_EMAIL First admin user email
ADMIN_PASSWORD First admin user password
DF_LICENSE_KEY Commercial license key

Secrets (in Secret Manager)

Secret Description
dreamfactory-app-key Laravel APP_KEY (auto-generated)
dreamfactory-db-password Cloud SQL password (auto-generated)
dreamfactory-license-key DreamFactory license key

Scaling

Adjust Cloud Run settings after deployment:

# Increase resources
gcloud run services update dreamfactory \
  --region=us-central1 \
  --memory=2Gi \
  --cpu=2

# Scale instances
gcloud run services update dreamfactory \
  --region=us-central1 \
  --min-instances=2 \
  --max-instances=20

# Use a larger DB
gcloud sql instances patch dreamfactory-db \
  --tier=db-n1-standard-2

Custom Domain

# Map your domain
gcloud run domain-mappings create \
  --service=dreamfactory \
  --domain=api.yourdomain.com \
  --region=us-central1

# Follow the DNS instructions printed by the command above

Manual Deployment

If you prefer to provision resources manually:

  1. Create Cloud SQL instance:

    gcloud sql instances create dreamfactory-db \
      --database-version=MYSQL_8_0 \
      --tier=db-g1-small \
      --region=us-central1
    gcloud sql databases create dreamfactory --instance=dreamfactory-db
    gcloud sql users create dreamfactory --instance=dreamfactory-db --password=YOUR_PASSWORD
  2. Create secrets:

    echo -n "base64:$(openssl rand -base64 32)" | gcloud secrets create dreamfactory-app-key --data-file=-
    echo -n "YOUR_DB_PASSWORD" | gcloud secrets create dreamfactory-db-password --data-file=-
    echo -n "YOUR_LICENSE_KEY" | gcloud secrets create dreamfactory-license-key --data-file=-
  3. Deploy Cloud Run:

    gcloud run deploy dreamfactory \
      --image=us-docker.pkg.dev/dreamfactory-public/dreamfactory/dreamfactory-cloud-run:latest \
      --region=us-central1 \
      --add-cloudsql-instances=PROJECT:REGION:dreamfactory-db \
      --set-secrets="APP_KEY=dreamfactory-app-key:latest,DB_PASSWORD=dreamfactory-db-password:latest,DF_LICENSE_KEY=dreamfactory-license-key:latest" \
      --set-env-vars="DB_CONNECTION=mysql,DB_HOST=127.0.0.1,DB_DATABASE=dreamfactory,DB_USERNAME=dreamfactory,CACHE_DRIVER=database,SESSION_DRIVER=database,ADMIN_EMAIL=admin@example.com,ADMIN_PASSWORD=YOUR_PASSWORD" \
      --min-instances=1 --max-instances=10 \
      --memory=1Gi --cpu=1 --timeout=300 \
      --allow-unauthenticated --port=8080

Troubleshooting

Container fails to start

Check logs:

gcloud run services logs read dreamfactory --region=us-central1 --limit=50

Database connection errors

Verify the Cloud SQL Auth Proxy sidecar is configured:

gcloud run services describe dreamfactory --region=us-central1 \
  --format="value(spec.template.metadata.annotations['run.googleapis.com/cloudsql-instances'])"

Migrations fail on boot

Connect to the database directly to debug:

gcloud sql connect dreamfactory-db --user=dreamfactory --database=dreamfactory

Cold start timeouts

Increase minimum instances:

gcloud run services update dreamfactory --region=us-central1 --min-instances=2

Out of memory

Increase memory allocation:

gcloud run services update dreamfactory --region=us-central1 --memory=2Gi

About

Deployment scripts and build files for DreamFactory to run in Google Cloud Run

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors