.do
ScaleServices-as-Software

Service Deployment

Deploy and launch Services-as-Software

Learn how to deploy and launch your Services-as-Software on the .do platform.

Deployment Overview

Services on .do are deployed to Cloudflare's global network:

  • 300+ locations worldwide
  • Zero cold starts with always-warm workers
  • Automatic scaling from 0 to millions of requests
  • Global distribution with millisecond latency
  • Built-in DDoS protection

Quick Deploy

Deploy your service with one command:

# Deploy to production
$ do deploy

# Deploy to staging
$ do deploy --env staging

# Deploy with specific version
$ do deploy --version 1.2.0

Deployment Process

flowchart TD Start[Start Deployment] --> Validate[Validate Service] Validate --> Pass1{Valid?} Pass1 -->|No| Error1[Show Errors] Pass1 -->|Yes| Build[Build & Bundle] Build --> Upload[Upload to CDN] Upload --> Deploy[Deploy to Edge] Deploy --> Health[Health Checks] Health --> Pass2{Healthy?} Pass2 -->|No| Rollback[Auto Rollback] Pass2 -->|Yes| Traffic[Route Traffic] Traffic --> Monitor[Monitor Metrics] Monitor --> Done[Deployment Complete]

1. Pre-Deployment Checks

Before deploying, the platform validates your service:

$ do validate

 Service configuration valid
 All dependencies installed
 Tests passing
 No security vulnerabilities
 Pricing configuration valid
 API endpoints accessible
 Event handlers registered

2. Build and Bundle

The platform builds your service:

$ do build

Building service...
 Bundling TypeScript
 Optimizing code
 Generating manifest
 Creating deployment package

Build complete: 245 KB

3. Deploy

Deploy to the global network:

$ do deploy

Deploying to production...
 Uploading service bundle
 Deploying to 300+ locations
 Registering event handlers
 Setting up API endpoints
 Configuring monitoring

Deployed successfully!

Service URL: https://customer-support.do
API URL: https://api.customer-support.do
Dashboard: https://dashboard.do/services/customer-support

Deployment Environments

Production

Deploy to production environment:

$ do deploy --env production

# Or use shorthand
$ do deploy --prod

Production deployments:

  • Serve real customers
  • Bill based on usage
  • Full monitoring and alerting
  • High availability (99.99% SLA)

Staging

Deploy to staging environment:

$ do deploy --env staging

# Or use shorthand
$ do deploy --stage

Staging deployments:

  • Test before production
  • No billing
  • Separate database
  • Full feature parity with production

Development

Deploy to development environment:

$ do deploy --env development

# Or use shorthand
$ do deploy --dev

Development deployments:

  • For testing integrations
  • No billing
  • Verbose logging
  • Faster deployment

Deployment Configuration

Configure deployment in do.config.ts:

export default {
  deployment: {
    // Deployment environment
    env: 'production',

    // Regions (default: all)
    regions: ['us-east', 'eu-west', 'ap-southeast'],

    // Scaling configuration
    scaling: {
      min: 0, // Minimum instances
      max: 100, // Maximum instances
      target: 80, // Target CPU %
    },

    // Health checks
    health: {
      path: '/health',
      interval: 30, // seconds
      timeout: 5, // seconds
      unhealthyThreshold: 3,
    },

    // Deployment strategy
    strategy: 'rolling', // or 'blue-green', 'canary'

    // Rollback configuration
    rollback: {
      automatic: true,
      errorThreshold: 0.05, // 5% error rate
      window: '5m',
    },
  },
}

Deployment Strategies

graph TB subgraph "Rolling Deployment" R1[Deploy 25%] --> R2[Monitor] R2 --> R3[Deploy 50%] R3 --> R4[Monitor] R4 --> R5[Deploy 100%] end subgraph "Blue-Green Deployment" BG1[Deploy Green] --> BG2[Test 10%] BG2 --> BG3[Switch 100%] BG3 --> BG4[Keep Blue for Rollback] end subgraph "Canary Deployment" C1[Deploy Canary] --> C2[10% Traffic] C2 --> C3[25% Traffic] C3 --> C4[50% Traffic] C4 --> C5[100% Traffic] end

Rolling Deployment

Default strategy - gradual rollout:

deployment: {
  strategy: 'rolling',
  rolling: {
    batchSize: 25,  // % of instances
    batchInterval: '2m',  // Wait between batches
  },
}

Process:

  1. Deploy to 25% of instances
  2. Monitor for 2 minutes
  3. If healthy, deploy to next 25%
  4. Repeat until 100% deployed

Blue-Green Deployment

Zero-downtime deployments:

deployment: {
  strategy: 'blue-green',
  blueGreen: {
    testTrafficPercent: 10,  // Send 10% to new version
    testDuration: '10m',  // Test for 10 minutes
  },
}

Process:

  1. Deploy new version (green)
  2. Send 10% of traffic to green
  3. Monitor for 10 minutes
  4. If healthy, switch 100% to green
  5. Keep blue for rollback

Canary Deployment

Gradual traffic shift:

deployment: {
  strategy: 'canary',
  canary: {
    steps: [
      { percent: 10, duration: '5m' },
      { percent: 25, duration: '10m' },
      { percent: 50, duration: '15m' },
      { percent: 100, duration: 'forever' },
    ],
    metrics: {
      errorRate: { max: 0.05 },
      latency: { max: 2000 },
    },
  },
}

Process:

  1. Deploy new version
  2. Send 10% of traffic, monitor for 5m
  3. If healthy, increase to 25%, monitor 10m
  4. Continue until 100%
  5. Auto-rollback if metrics exceed thresholds

Version Management

Semantic Versioning

Use semantic versioning:

# Patch version (1.0.0 → 1.0.1)
$ do deploy --version patch

# Minor version (1.0.1 → 1.1.0)
$ do deploy --version minor

# Major version (1.1.0 → 2.0.0)
$ do deploy --version major

# Specific version
$ do deploy --version 2.1.0

Version History

View deployment history:

$ do versions

Version    Date                Status      Traffic
2.1.0      2025-10-24 14:30   Active      100%
2.0.1      2025-10-20 10:15   Retired     0%
2.0.0      2025-10-15 09:00   Retired     0%
1.5.3      2025-10-10 16:45   Retired     0%

Rollback

Rollback to previous version:

# Rollback to previous version
$ do rollback

# Rollback to specific version
$ do rollback --version 2.0.1

# Automatic rollback on errors
$ do deploy --auto-rollback

Zero-Downtime Deployments

Ensure zero downtime during deployments:

Health Checks

Define health checks:

api: {
  'GET /health': () => {
    // Check database connectivity
    const dbHealthy = await $.db.ping()

    // Check AI service
    const aiHealthy = await $.ai.health()

    // Check external APIs
    const apisHealthy = await checkExternalAPIs()

    if (dbHealthy && aiHealthy && apisHealthy) {
      return { status: 'healthy' }
    }

    return {
      status: 'unhealthy',
      details: { dbHealthy, aiHealthy, apisHealthy },
    }
  },
}

Graceful Shutdown

Handle in-flight requests:

export default service({
  name: 'My Service',

  // Lifecycle hooks
  lifecycle: {
    // Called before shutdown
    beforeShutdown: async () => {
      // Finish processing current requests
      await finishCurrentRequests()

      // Close database connections
      await $.db.close()

      // Flush logs
      await $.log.flush()
    },
  },
})

Monitoring Deployment

Deployment Logs

View deployment logs:

$ do deploy:logs

2025-10-24 14:30:00  Starting deployment
2025-10-24 14:30:05  Building service
2025-10-24 14:30:15  Uploading to 300+ locations
2025-10-24 14:30:30  Deployment 25% complete
2025-10-24 14:30:45  Deployment 50% complete
2025-10-24 14:31:00  Deployment 75% complete
2025-10-24 14:31:15  Deployment 100% complete
2025-10-24 14:31:20  Health checks passing
2025-10-24 14:31:25  Deployment successful

Real-Time Metrics

Monitor during deployment:

$ do deploy:watch

Deploying version 2.1.0...

Progress: ████████████░░░░░░░░ 60%

Metrics:
  Requests/sec:    1,250
  Error rate:      0.02%
  Latency p99:     145ms
  Health: All regions healthy

Traffic Split:
  v2.1.0 (new):    60%
  v2.0.1 (old):    40%

CI/CD Integration

GitHub Actions

Automate deployments:

# .github/workflows/deploy.yml
name: Deploy Service

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Install Dependencies
        run: pnpm install

      - name: Run Tests
        run: pnpm test

      - name: Deploy to Production
        run: do deploy --prod
        env:
          DO_API_KEY: ${{ secrets.DO_API_KEY }}

GitLab CI

# .gitlab-ci.yml
deploy:
  stage: deploy
  script:
    - pnpm install
    - pnpm test
    - do deploy --prod
  only:
    - main
  environment:
    name: production
    url: https://customer-support.do

Multi-Region Deployment

Deploy to specific regions:

# Deploy to specific regions
$ do deploy --regions us-east,eu-west,ap-southeast

# Deploy to all regions
$ do deploy --regions all

# Deploy to nearby regions only
$ do deploy --regions auto

Configure regions in do.config.ts:

deployment: {
  regions: [
    {
      name: 'us-east',
      weight: 40,  // 40% of traffic
      priority: 1,
    },
    {
      name: 'eu-west',
      weight: 30,  // 30% of traffic
      priority: 1,
    },
    {
      name: 'ap-southeast',
      weight: 30,  // 30% of traffic
      priority: 2,
    },
  ],
}

Deployment Secrets

Manage secrets for deployment:

# Set secret
$ do secret set STRIPE_API_KEY=sk_live_...

# List secrets
$ do secret list

# Delete secret
$ do secret delete STRIPE_API_KEY

# Rotate secret
$ do secret rotate STRIPE_API_KEY --new-value sk_live_new...

Access in service:

const apiKey = process.env.STRIPE_API_KEY

Custom Domains

Use custom domains:

# Add custom domain
$ do domain add customer-support.example.com

# Add SSL certificate (automatic with Let's Encrypt)
$ do ssl setup customer-support.example.com

# List domains
$ do domain list

# Remove domain
$ do domain remove customer-support.example.com

Configure in DNS:

CNAME customer-support.example.com → customer-support.do

Launch Checklist

Before launching your service:

  • All tests passing
  • Load testing completed
  • Security scan passed
  • Documentation updated
  • Pricing configured
  • Monitoring set up
  • Alerts configured
  • Custom domain configured
  • SSL certificate installed
  • Backup strategy defined
  • Rollback plan tested
  • Team trained
  • Support channels ready

Post-Launch Monitoring

After deployment, monitor:

# View real-time logs
$ do logs --follow

# View metrics dashboard
$ do metrics --dashboard

# View active alerts
$ do alerts --active

# Check service health
$ do health

Troubleshooting Deployments

Deployment Fails

Check deployment logs:

$ do deploy:logs --failed

Error: Health checks failing
 /health endpoint returning 503
 Database connection timeout

Resolution:
 Check database connectivity
 Verify environment variables

Rollback

If deployment has issues:

# Automatic rollback
$ do rollback

Rolling back to version 2.0.1...
 Switching traffic
 Health checks passing
 Rollback complete

Debug Mode

Deploy with debug logging:

$ do deploy --debug

# View verbose logs
$ do logs --level debug

Next Steps