DigitalOcean Deployment Guide
Deploy SelfHostedDB on DigitalOcean
This guide covers deploying SelfHostedDB on DigitalOcean using Droplets or App Platform.
Option 1: DigitalOcean Droplet
Best for: Simple, cost-effective deployments
Steps
-
Create Droplet
- Ubuntu 22.04 LTS
- Minimum: 2GB RAM, 1 vCPU ($12/month)
- Recommended: 4GB RAM, 2 vCPU ($24/month)
-
Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh sudo usermod -aG docker $USER -
Deploy Application
docker run -d \ --name selfhosteddb \ --restart unless-stopped \ -p 3001:3001 \ -e DATABASE_URL='postgres://...' \ -e AUTH_USER='admin' \ -e AUTH_PASS='your-password' \ -e NODE_ENV=production \ your-registry/selfhosteddb:latest -
Set Up Load Balancer (Optional)
- Create DigitalOcean Load Balancer
- Point to droplet on port 3001
- Configure SSL certificate (Let's Encrypt)
Database Options
- DigitalOcean Managed Database: PostgreSQL cluster
- Self-hosted: PostgreSQL container on same droplet
Option 2: DigitalOcean App Platform
Best for: Managed deployments, automatic scaling
Steps
-
Create App Specification
name: selfhosteddb services: - name: selfhosteddb github: repo: your-username/db-tool-pgvista branch: main dockerfile_path: Dockerfile http_port: 3001 instance_count: 1 instance_size_slug: basic-xxs envs: - key: DATABASE_URL scope: RUN_TIME type: SECRET - key: AUTH_USER scope: RUN_TIME type: SECRET - key: AUTH_PASS scope: RUN_TIME type: SECRET - key: NODE_ENV value: production - key: PORT value: "3001" -
Deploy via CLI
doctl apps create --spec app.yaml -
Configure Secrets
- Use DigitalOcean App Platform secrets
- Set via dashboard or CLI
Monitoring
DigitalOcean Monitoring
- Metrics: CPU, memory, disk, network
- Alerts: Set up alerting policies
- Dashboards: View metrics in dashboard
Logs
- Application Logs: View in App Platform dashboard
- Droplet Logs: Use
journalctlor Docker logs
Security Best Practices
- Use DigitalOcean App Platform secrets
- Enable firewall (UFW) on droplets
- Use SSH keys instead of passwords
- Enable fail2ban for brute force protection
- Use SSL/TLS for all connections
Cost Optimization
- Droplets: Use smaller instances and scale up as needed
- App Platform: Use auto-scaling to reduce costs
- Managed Database: Use smaller plans for development
Related Documentation
- Production Deployment Guide - General production deployment
- Security Best Practices - Security configuration
- Troubleshooting Guide - Common issues
- Installation Guide - Initial setup
Last Updated: 2025-01-27