Deploy to DigitalOcean App Platform

Deploy WhatsApp Team Inbox to DigitalOcean App Platform with managed PostgreSQL and automatic scaling.

TL;DR - Quick Deploy

1

Create App

DigitalOcean Apps → Create App → GitHub → Select repo
2

Configure Services

Deploy as Docker Compose OR separate backend + frontend services
3

Add PostgreSQL

Add Database → PostgreSQL 16 → Basic plan ($15/month)
4

Set Variables

Add WhatsApp credentials, JWT secrets, admin credentials
Total time: ~15 minutes | Cost: $32/month (app + database)

Why DigitalOcean App Platform?

Simple Pricing

Predictable pricing starting at $12/month

Managed Database

Fully managed PostgreSQL with backups

Auto Scaling

Automatic horizontal and vertical scaling

Global CDN

Built-in CDN for static assets

Prerequisites

DigitalOcean account (sign up at digitalocean.com)
GitHub account
WhatsApp Business API credentials
Credit card for DigitalOcean billing

Deployment Options

Deploy entire stack as a single Docker app:
1

Fork Repository

Fork the WhatsApp Team Inbox repository
2

Create App

  1. Go to DigitalOcean Apps
  2. Click Create App
  3. Select GitHub as source
  4. Choose your forked repository
  5. Select branch: main
3

Configure as Docker App

Type: Docker ComposeDockerfile Path: docker-compose.ymlDigitalOcean will detect docker-compose.yml automatically
4

Add PostgreSQL Database

  1. Click Add ResourceDatabase
  2. Select PostgreSQL 16
  3. Choose plan:
    • Basic: $15/month (1GB RAM, 10GB storage)
    • Professional: $55/month (4GB RAM, 38GB storage)
5

Configure Environment Variables

Add required environment variables (see below)
6

Deploy

Click Create Resources to start deployment

Option 2: Separate Services

Deploy frontend and backend as separate apps:
1

Create Backend App

  1. Create AppGitHub
  2. Select repository
  3. Type: Dockerfile
  4. Source Directory: /backend
  5. Dockerfile Path: backend/Dockerfile
  6. HTTP Port: 4000
2

Create Frontend App

  1. Create AppGitHub
  2. Select same repository
  3. Type: Node.js
  4. Source Directory: /web
  5. Build Command: npm run build
  6. Run Command: npm start
3

Create Database

  1. Go to Databases in DigitalOcean
  2. Create Database Cluster
  3. Select PostgreSQL 16
  4. Choose datacenter region
  5. Select plan size
4

Connect Database to App

  1. Open your backend app
  2. Go to SettingsApp-Level Environment Variables
  3. Add DATABASE_URL with connection string from database

Environment Variables

Configure in App Platform → SettingsEnvironment Variables:

Backend Variables

# DigitalOcean provides this automatically if using managed database
DATABASE_URL=${db.DATABASE_URL}
WHATSAPP_API_URL=https://graph.facebook.com/v21.0
WHATSAPP_ACCESS_TOKEN=your_permanent_access_token
WHATSAPP_PHONE_NUMBER_ID=123456789012345
WHATSAPP_BUSINESS_ACCOUNT_ID=123456789012345
WHATSAPP_WEBHOOK_VERIFY_TOKEN=generate_random_token
Generate verify token:
openssl rand -hex 16
JWT_SECRET=generate_with_openssl_rand_hex_32
JWT_REFRESH_SECRET=generate_different_secret
JWT_EXPIRES_IN=7d
JWT_REFRESH_EXPIRES_IN=30d
Generate secrets:
openssl rand -hex 32
ADMIN_EMAIL=admin@yourcompany.com
ADMIN_PASSWORD=strong_password_here
ADMIN_FIRST_NAME=System
ADMIN_LAST_NAME=Administrator
NODE_ENV=production
PORT=4000
WS_PORT=4001
CORS_ORIGIN=${APP_URL}
${APP_URL} automatically resolves to your app’s URL

Frontend Variables

NEXT_PUBLIC_API_BASE_URL=${backend.PUBLIC_URL}
NEXT_PUBLIC_WS_URL=wss://${backend.PUBLIC_URL}
DigitalOcean automatically replaces ${service.VARIABLE} with actual service values

Database Setup

Managed PostgreSQL

1

Create Database Cluster

  1. Go to Databases in DigitalOcean control panel
  2. Click Create Database Cluster
  3. Select PostgreSQL version 16
2

Choose Configuration

Basic Plan:
  • 1 GB RAM / 1 vCPU / 10 GB Disk: $15/month
  • 2 GB RAM / 1 vCPU / 25 GB Disk: $30/month
  • 4 GB RAM / 2 vCPU / 38 GB Disk: $55/month
Professional Plan (HA):
  • Automatic failover
  • Standby nodes
  • Higher performance
3

Select Region

Choose region closest to your users:
  • New York (NYC)
  • San Francisco (SFO)
  • Amsterdam (AMS)
  • Singapore (SGP)
  • London (LON)
4

Configure Security

  1. Enable Trusted Sources
  2. Add your App Platform app
  3. Optionally add your IP for database access
5

Create Database

  1. Database name: whatsapp_inbox
  2. Click Create Database Cluster

Connection Pooling

Enable connection pooling for better performance:
1

Access Database Settings

Database → SettingsConnection Pools
2

Create Pool

  • Name: whatsapp-pool
  • Database: whatsapp_inbox
  • Mode: Transaction
  • Size: 25
3

Use Pool Connection String

Update DATABASE_URL to use pool connection string instead of direct connection

Custom Domain

Add Custom Domain

1

Access Domain Settings

App → SettingsDomains
2

Add Domain

Click Add Domain and enter:
  • Frontend: app.your-domain.com
  • Backend: api.your-domain.com
3

Configure DNS

Add CNAME records at your domain registrar:
Type: CNAME
Name: app
Value: your-app.ondigitalocean.app
TTL: 3600
Type: CNAME
Name: api
Value: your-api.ondigitalocean.app
TTL: 3600
4

Verify Domain

DigitalOcean will verify domain and issue SSL certificate automaticallyUsually takes 5-10 minutes
5

Update Environment Variables

Update CORS and frontend URLs to use custom domain:
# Backend
CORS_ORIGIN=https://app.your-domain.com

# Frontend
NEXT_PUBLIC_API_BASE_URL=https://api.your-domain.com

Monitoring

Built-in Monitoring

DigitalOcean App Platform provides monitoring out of the box:

Metrics

  • CPU usage
  • Memory usage
  • Request count
  • Response time

Logs

  • Application logs
  • Build logs
  • Deploy logs
  • Real-time streaming

Alerts

  • Resource usage alerts
  • Deployment alerts
  • Custom metrics

Health Checks

  • HTTP health checks
  • Auto-restart on failure
  • Configurable intervals

Configure Health Checks

1

Access Health Check Settings

App → SettingsHealth Checks
2

Configure Backend Health Check

  • Path: /health
  • Port: 4000
  • Initial Delay: 30 seconds
  • Period: 10 seconds
  • Timeout: 5 seconds
  • Success Threshold: 1
  • Failure Threshold: 3
3

Configure Frontend Health Check

  • Path: /
  • Port: 3000
  • Initial Delay: 30 seconds

Set Up Alerts

1

Create Alert Policy

App → SettingsAlerts
2

Configure Alerts

Enable alerts for:
  • ✅ Deployment failures
  • ✅ High CPU usage (>80%)
  • ✅ High memory usage (>90%)
  • ✅ Health check failures
  • ✅ Crash loop detected
3

Add Notification Channels

  • Email notifications
  • Slack webhook
  • PagerDuty integration

Scaling

Vertical Scaling

Upgrade resources for better performance:
1

Access Scaling Settings

App → SettingsResources & Scaling
2

Choose Container Size

Basic:
  • 512 MB / 0.5 vCPU: $5/month
  • 1 GB / 1 vCPU: $12/month
  • 2 GB / 1 vCPU: $24/month
Professional:
  • 4 GB / 2 vCPU: $48/month
  • 8 GB / 4 vCPU: $96/month
3

Apply Changes

Click Save - App will redeploy with new resources

Horizontal Scaling

Scale to multiple containers for high availability:
1

Enable Auto-Scaling

App → SettingsAuto Scaling
2

Configure Rules

  • Minimum Instances: 2
  • Maximum Instances: 10
  • CPU Threshold: 70%
  • Memory Threshold: 80%
3

Load Balancing

DigitalOcean automatically load balances across instances

Backups

Database Backups

Automatic backups are included:
Retention:
  • Daily backups: 7 days
  • Weekly backups: 4 weeks
  • Monthly backups: 3 months

Manual Backup

1

Create Manual Backup

Database → BackupsCreate Backup
2

Download Backup

Click on backup → Download
3

Restore from Backup

Database → Backups → Select backup → Restore

Application Backups

Backup your application configuration:
# Install doctl (DigitalOcean CLI)
brew install doctl  # macOS
snap install doctl  # Linux

# Authenticate
doctl auth init

# Export app spec
doctl apps spec get YOUR_APP_ID > app-spec.yaml

# Later, restore from spec
doctl apps create --spec app-spec.yaml

CI/CD

Automatic Deployments

App Platform automatically deploys on git push:
1

Configure Auto-Deploy

App → SettingsSourceAutodeploy - Enable auto-deploy on push to main
2

Push to GitHub

git add .
git commit -m "Update feature"
git push origin main
DigitalOcean detects push and deploys automatically
3

Monitor Deployment

Watch deployment progress in App Platform dashboard

Deploy Specific Branch

1

Change Source Branch

App → SettingsSourceBranch
2

Select Branch

Choose branch to deploy:
  • main - Production
  • staging - Staging environment
  • develop - Development
3

Trigger Deployment

Click Force Rebuild and Deploy

Cost Optimization

Estimate Monthly Costs

Example small team setup:
ServiceSizeCost
Backend App1GB RAM$12/month
Frontend App512MB RAM$5/month
PostgreSQL1GB/10GB$15/month
Total$32/month

Tips to Reduce Costs

Begin with Basic plans and upgrade when needed based on metrics
Reduce database costs by using connection pooling instead of multiple connections
  • Use multi-stage builds
  • Remove unused dependencies
  • Use Alpine base images
Use DigitalOcean’s built-in CDN for static assets to reduce bandwidth costs
Adjust backup frequency based on your data change rate

Troubleshooting

Common causes:
  • Dockerfile errors
  • Missing dependencies
  • Build timeout
Solutions:
  1. Check build logs in deployment history
  2. Test Docker build locally: docker build -f backend/Dockerfile .
  3. Verify all dependencies in package.json
  4. Increase build timeout in settings
Causes:
  • Trusted sources not configured
  • DATABASE_URL incorrect
  • Connection limit reached
Solutions:
  1. Add app to database trusted sources
  2. Verify DATABASE_URL in environment variables
  3. Enable connection pooling
  4. Check database logs for errors
Causes:
  • Insufficient memory
  • Application error
  • Missing environment variables
Solutions:
  1. Check runtime logs for errors
  2. Increase container size
  3. Verify all required env vars are set
  4. Test locally with same environment
Causes:
  • Undersized resources
  • Database not optimized
  • No CDN for assets
Solutions:
  1. Monitor metrics and scale up if needed
  2. Add database indexes
  3. Enable CDN for static assets
  4. Use connection pooling

Production Checklist

All environment variables configured
Database backups enabled
Health checks configured
Custom domain added
SSL certificates active
Monitoring and alerts set up
Auto-scaling configured
WhatsApp webhook tested
Connection pooling enabled
CDN enabled for static assets

DigitalOcean CLI

For advanced users, use doctl:

Installation

# macOS
brew install doctl

# Linux
snap install doctl

# Windows
scoop install doctl

Common Commands

# Authenticate
doctl auth init

# List apps
doctl apps list

# Get app info
doctl apps get YOUR_APP_ID

# View logs
doctl apps logs YOUR_APP_ID --follow

# Create deployment
doctl apps create-deployment YOUR_APP_ID

# List databases
doctl databases list

# Database connection info
doctl databases connection YOUR_DB_ID

Migration from Other Platforms

From Heroku

1

Export Heroku Data

# Export database
heroku pg:backups:capture -a your-app
heroku pg:backups:download -a your-app

# Export environment variables
heroku config -a your-app > heroku-config.txt
2

Import to DigitalOcean

  1. Create DigitalOcean database
  2. Restore backup:
    pg_restore -d DATABASE_URL latest.dump
    
  3. Copy environment variables to App Platform
3

Update DNS

Point your domain to DigitalOcean:
CNAME: your-app.ondigitalocean.app

Next Steps

Resources