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.0Deployment Process
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 registered2. Build and Bundle
The platform builds your service:
$ do build
Building service...
→ Bundling TypeScript
→ Optimizing code
→ Generating manifest
→ Creating deployment package
Build complete: 245 KB3. 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-supportDeployment Environments
Production
Deploy to production environment:
$ do deploy --env production
# Or use shorthand
$ do deploy --prodProduction 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 --stageStaging 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 --devDevelopment 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
Rolling Deployment
Default strategy - gradual rollout:
deployment: {
strategy: 'rolling',
rolling: {
batchSize: 25, // % of instances
batchInterval: '2m', // Wait between batches
},
}Process:
- Deploy to 25% of instances
- Monitor for 2 minutes
- If healthy, deploy to next 25%
- 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:
- Deploy new version (green)
- Send 10% of traffic to green
- Monitor for 10 minutes
- If healthy, switch 100% to green
- 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:
- Deploy new version
- Send 10% of traffic, monitor for 5m
- If healthy, increase to 25%, monitor 10m
- Continue until 100%
- 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.0Version 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-rollbackZero-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 successfulReal-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.doMulti-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 autoConfigure 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_KEYCustom 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.comConfigure in DNS:
CNAME customer-support.example.com → customer-support.doLaunch 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 healthTroubleshooting 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 variablesRollback
If deployment has issues:
# Automatic rollback
$ do rollback
Rolling back to version 2.0.1...
→ Switching traffic
→ Health checks passing
→ Rollback completeDebug Mode
Deploy with debug logging:
$ do deploy --debug
# View verbose logs
$ do logs --level debugNext Steps
- Monetization - Set up pricing and billing
- Lifecycle Management - Manage service versions
- Best Practices - Deployment best practices