infinite-agents-public/deployment/DEPLOYMENT_GUIDE.md

237 lines
5.3 KiB
Markdown

# Deployment Guide for agents.jeffemmett.com
This guide will help you deploy the Infinite Agents dashboard to your DigitalOcean droplet with automatic GitHub Actions deployments.
## 🎯 Overview
- **Production URL**: https://agents.jeffemmett.com
- **Droplet IP**: 143.198.39.165
- **Web Server**: Nginx with SSL (Let's Encrypt)
- **Auto-Deploy**: GitHub Actions on push to `main`
## 📋 Prerequisites
1. DigitalOcean droplet at 143.198.39.165
2. Domain `agents.jeffemmett.com` DNS configured in Cloudflare
3. SSH access to the droplet
4. GitHub repository access
## 🚀 Initial Setup
### Step 1: Configure DNS in Cloudflare
In Cloudflare DNS settings for `jeffemmett.com`:
```
Type: A
Name: agents
Content: 143.198.39.165
Proxy status: DNS only (gray cloud)
TTL: Auto
```
**Important**: Set to "DNS only" (not proxied) for initial SSL setup.
### Step 2: Run Setup Script on Droplet
SSH into your droplet and run the setup script:
```bash
# SSH into droplet
ssh root@143.198.39.165
# Clone the repository temporarily to get setup script
git clone https://github.com/Jeff-Emmett/infinite-agents.git /tmp/setup
cd /tmp/setup
# Make script executable and run it
chmod +x deployment/setup-droplet.sh
./deployment/setup-droplet.sh
```
The script will:
- Install nginx, Node.js, Python
- Clone the repository to `/var/www/agents.jeffemmett.com`
- Configure nginx with SSL
- Set up automatic SSL renewal
- Deploy the site
### Step 3: Configure GitHub Secrets
Add the following secrets to your GitHub repository:
**Go to**: Repository → Settings → Secrets and variables → Actions → New repository secret
Add these three secrets:
1. **DROPLET_HOST**
```
143.198.39.165
```
2. **DROPLET_USER**
```
root
```
3. **DROPLET_SSH_KEY**
- Your private SSH key for the droplet
- To get it: `cat ~/.ssh/id_rsa` (on your local machine)
- Copy the entire key including `-----BEGIN` and `-----END` lines
### Step 4: Test Deployment
Push a change to the `main` branch or trigger the workflow manually:
```bash
# Trigger manually via GitHub UI
Go to: Actions → Deploy to DigitalOcean Droplet → Run workflow
# Or push a change
git push origin main
```
## 🔧 Manual Deployment (if needed)
If you need to deploy manually:
```bash
ssh root@143.198.39.165
cd /var/www/agents.jeffemmett.com
git pull origin main
npm ci
python3 generate_index.py
chown -R www-data:www-data .
systemctl reload nginx
```
## 📊 Monitoring & Logs
### Check nginx status
```bash
systemctl status nginx
```
### View nginx logs
```bash
# Access log
tail -f /var/log/nginx/agents.jeffemmett.com-access.log
# Error log
tail -f /var/log/nginx/agents.jeffemmett.com-error.log
```
### Test nginx configuration
```bash
nginx -t
```
## 🔐 SSL Certificate
SSL certificates are managed by Let's Encrypt and auto-renew.
### Check certificate status
```bash
certbot certificates
```
### Manual renewal (if needed)
```bash
certbot renew
systemctl reload nginx
```
## 🔄 Updating the Site
Updates are automatic! Just push to `main`:
1. Make changes locally
2. Commit and push to `main`
3. GitHub Actions automatically deploys
4. Site updates in ~2 minutes
## 🐛 Troubleshooting
### Site not loading?
- Check DNS propagation: `dig agents.jeffemmett.com`
- Verify nginx is running: `systemctl status nginx`
- Check nginx logs for errors
### Deployment failing?
- Verify GitHub secrets are set correctly
- Check GitHub Actions logs
- Ensure SSH key has proper permissions
### SSL errors?
- Ensure DNS is pointing to droplet IP
- Run: `certbot renew --dry-run`
- Check certificate: `certbot certificates`
## 📁 Directory Structure
```
/var/www/agents.jeffemmett.com/
├── .github/workflows/
│ ├── deploy.yml # GitHub Pages deployment
│ └── deploy-droplet.yml # Droplet deployment
├── deployment/
│ ├── nginx-config.conf # Nginx configuration
│ ├── setup-droplet.sh # Initial setup script
│ └── DEPLOYMENT_GUIDE.md # This file
├── index.html # Generated dashboard
├── src/ # UI components
├── threejs_viz/ # Three.js demos
├── sdg_viz/ # SDG visualizations
└── [other demo directories]
```
## 🎯 Both Cloudflare Pages AND Droplet?
You can deploy to both!
- **Cloudflare Pages**: Automatic, global CDN, great for most users
- **Droplet**: Full control, custom server config, your own infrastructure
Both will deploy automatically on push to `main`.
## 🔗 Useful Commands
```bash
# SSH into droplet
ssh root@143.198.39.165
# Check deployment
cd /var/www/agents.jeffemmett.com && git status
# View recent commits
cd /var/www/agents.jeffemmett.com && git log -5 --oneline
# Restart nginx
systemctl restart nginx
# Test site locally
curl -I https://agents.jeffemmett.com
```
## ✅ Verification Checklist
After setup, verify:
- [ ] Site loads at https://agents.jeffemmett.com
- [ ] SSL certificate is valid (green lock icon)
- [ ] All demo categories display correctly
- [ ] GitHub Actions workflow runs successfully
- [ ] Push to main triggers auto-deployment
- [ ] Site updates after deployment completes
## 🆘 Support
If you encounter issues:
1. Check the troubleshooting section above
2. Review GitHub Actions logs
3. Check nginx error logs on droplet
4. Verify DNS settings in Cloudflare
---
**Happy deploying! 🚀**