5.6 KiB
Deployment Guide - DigitalOcean App Platform
This guide will help you deploy the Kiddos app to DigitalOcean's App Platform.
Prerequisites
- GitHub Repository: Push your code to GitHub
- DigitalOcean Account: Create an account at https://digitalocean.com
- Turso Database: Have your Turso credentials ready
- Get from: https://turso.tech
- YouTube API Key: Get from Google Cloud Console
- Visit: https://console.cloud.google.com
- Enable YouTube Data API v3
- Create API key
Step 1: Prepare Your Repository
-
Update
.do/app.yaml:# Edit .do/app.yaml # Replace YOUR_GITHUB_USERNAME/kiddos with your actual GitHub repo # Example: johndoe/kiddos -
Commit and push to GitHub:
git add . git commit -m "Add DigitalOcean deployment config" git push origin main
Step 2: Create App on DigitalOcean
- Go to https://cloud.digitalocean.com/apps
- Click "Create App"
- Select "GitHub" as source
- Authorize DigitalOcean to access your repository
- Select your
kiddosrepository - Choose your branch (usually
main) - DigitalOcean will detect
.do/app.yamlautomatically - Click "Next"
Step 3: Configure Environment Variables
DigitalOcean will prompt you to fill in the required environment variables (marked as ${VARIABLE} in app.yaml).
Required Secrets:
-
TURSO_URL
- Your Turso database URL
- Example:
libsql://your-database.turso.io
-
TURSO_AUTH_TOKEN
- Your Turso authentication token
- Get from Turso dashboard
-
YOUTUBE_API_KEY
- Your YouTube Data API v3 key
- Get from Google Cloud Console
-
JWT_SECRET
- A long random string (32+ characters)
- Generate with:
openssl rand -base64 32
-
JWT_REFRESH_SECRET
- A different long random string (32+ characters)
- Generate with:
openssl rand -base64 32
-
INITIAL_ADMIN_USERNAME
- Your admin username (e.g., "admin")
-
INITIAL_ADMIN_PASSWORD
- A secure password for admin account
- Make it strong!
Optional Variables:
These will be auto-populated by DigitalOcean:
APP_URL- Automatically set to your frontend URLbackend.PUBLIC_URL- Automatically set to your backend URL
Step 4: Review and Deploy
-
Review the configuration:
- Backend: Node.js service on Basic XXS ($5/month)
- Frontend: Static site (FREE)
-
Choose your datacenter region (default: NYC)
-
Click "Create Resources"
-
Wait for deployment (usually 5-10 minutes)
Step 5: Post-Deployment
Get Your URLs
After deployment completes, you'll have:
- Frontend URL:
https://kiddos-xxxxx.ondigitalocean.app - Backend URL:
https://kiddos-backend-xxxxx.ondigitalocean.app
Update CORS Settings (if needed)
If you have multiple domains or custom domain:
- Go to your app in DigitalOcean
- Click on "backend" component
- Go to "Environment Variables"
- Update
CORS_ORIGINto include your custom domain - Redeploy
Step 6: Test Your Deployment
- Visit your frontend URL
- You should see the video grid
- Click "Login"
- Use your admin credentials
- Go to "Admin" page
- Try adding a YouTube channel
Troubleshooting
Backend Fails to Start
Check logs:
- Go to your app in DigitalOcean
- Click on "backend" component
- Go to "Runtime Logs"
Common issues:
- Missing environment variables
- Invalid Turso credentials
- Invalid YouTube API key
Frontend Shows API Errors
Check:
- Frontend environment variables
- Backend is running (check backend URL)
- CORS is configured correctly
- Network tab in browser DevTools
Database Migration Fails
Solution:
- Check Turso database is accessible
- Verify
TURSO_URLandTURSO_AUTH_TOKEN - Check backend logs for specific error
Monitoring
View Logs
Backend logs:
App Platform → Your App → backend → Runtime Logs
Build logs:
App Platform → Your App → backend → Build Logs
View Metrics
App Platform → Your App → Insights
Shows:
- CPU usage
- Memory usage
- Request count
- Response times
Updating Your App
Automatic Deployments
When you push to your GitHub repository, DigitalOcean will automatically:
- Detect the change
- Build your app
- Run tests (if configured)
- Deploy new version
Manual Deployments
- Go to your app in DigitalOcean
- Click "Create Deployment"
- Select branch
- Click "Deploy"
Custom Domain (Optional)
- Go to your app → Settings → Domains
- Click "Add Domain"
- Enter your domain name
- Follow DNS configuration instructions
- Wait for SSL certificate provisioning
Cost Breakdown
- Backend (Basic XXS): $5/month
- Frontend (Static Site): FREE
- Turso Database: FREE tier (up to 9 GB)
- Bandwidth: 100 GB/month included
Total: ~$5/month
Scaling
To upgrade:
- Go to your app
- Click on "backend" component
- Go to "Resources"
- Choose a larger instance size
- Click "Save"
Available sizes:
- Basic XXS: $5/month (512 MB RAM)
- Basic XS: $12/month (1 GB RAM)
- Basic S: $25/month (2 GB RAM)
Support
- DigitalOcean Docs: https://docs.digitalocean.com/products/app-platform/
- Turso Docs: https://docs.turso.tech
- YouTube API Docs: https://developers.google.com/youtube/v3
Security Checklist
- ✅ All secrets stored as encrypted environment variables
- ✅ CORS configured to only allow your domain
- ✅ JWT tokens use httpOnly cookies
- ✅ Rate limiting enabled on API
- ✅ Admin password is strong
- ✅ HTTPS enabled automatically by DigitalOcean
Ready to deploy? Follow the steps above and you'll be live in minutes! 🚀