# Quick Deploy Reference - Domain Migration

**🚀 For: DevOps / Deployment Team**
**Domain**: workroot.com → workroot.in

---

## 🎯 Pre-Flight Checklist (5 minutes)

```bash
# 1. Verify DNS is propagated
dig workroot.in +short
# Should return: [YOUR_SERVER_IP]

# 2. Check SSL certificate exists
sudo certbot certificates | grep workroot.in
# Should show valid certificate

# 3. Verify code is up to date
cd /path/to/workroot-website
git status
git log -1
# Should show latest migration commit
```

---

## ⚡ Deployment Steps (15 minutes)

### 1. Pull Latest Code (2 min)
```bash
cd /path/to/workroot-website
git pull origin main
```

### 2. Install & Build (5 min)
```bash
npm ci --only=production
npm run build
```

### 3. Verify Build (1 min)
```bash
# Confirm new domain in build
grep -r "workroot.in" dist/client/ | head -5

# Confirm no old domain
! grep -r "workroot.com" dist/client/ || echo "⚠️  Old domain found!"
```

### 4. Update Nginx (3 min)
```bash
# Backup current config
sudo cp /etc/nginx/sites-available/workroot /etc/nginx/sites-available/workroot.bak

# Apply new config (see DOMAIN-MIGRATION-CHECKLIST.md Phase 3)
sudo nano /etc/nginx/sites-available/workroot

# Test configuration
sudo nginx -t

# Reload nginx
sudo systemctl reload nginx
```

### 5. Restart Application (2 min)
```bash
# Option A: PM2
pm2 restart workroot-website
pm2 save

# Option B: Systemd
sudo systemctl restart workroot

# Option C: Docker
docker-compose restart
```

### 6. Verify Deployment (2 min)
```bash
# Check application is running
curl -I https://workroot.in
# Should return: HTTP/2 200

# Check health endpoint
curl https://workroot.in/api/health.json
# Should return: {"status":"healthy",...}

# Check sitemap
curl https://workroot.in/api/sitemap.xml | grep "<loc>" | head -3
# Should contain: https://workroot.in URLs
```

---

## ✅ Post-Deployment Tests (5 minutes)

```bash
# Test redirects from old domain
curl -I https://workroot.com
# Should return: HTTP/1.1 301 Moved Permanently
# Location: https://workroot.in

curl -I http://workroot.com
# Should return: HTTP/1.1 301 Moved Permanently

curl -I https://www.workroot.com
# Should return: HTTP/1.1 301 Moved Permanently
# Location: https://workroot.in

# Test SSL
echo | openssl s_client -connect workroot.in:443 -servername workroot.in 2>/dev/null | grep "Verify return code"
# Should return: Verify return code: 0 (ok)

# Check logs
pm2 logs workroot-website --lines 50
# Should show no errors
```

---

## 🔥 Quick Rollback (Emergency)

```bash
# 1. Restore nginx config
sudo cp /etc/nginx/sites-available/workroot.bak /etc/nginx/sites-available/workroot
sudo nginx -t && sudo systemctl reload nginx

# 2. Deploy previous version
git log --oneline -10  # Find previous commit
git checkout [PREVIOUS_COMMIT_HASH]
npm ci --only=production
npm run build
pm2 restart workroot-website

# 3. Verify
curl -I https://workroot.com  # Should work
```

---

## 📊 Health Monitoring

```bash
# Watch logs live
pm2 logs workroot-website

# Check server resources
htop
df -h

# Monitor nginx access logs
sudo tail -f /var/log/nginx/access.log | grep workroot

# Check for errors
sudo tail -f /var/log/nginx/error.log
```

---

## 🆘 Common Issues

### Issue: Port 10000 already in use
```bash
# Find and kill process
lsof -i :10000
kill -9 [PID]

# Or restart PM2
pm2 restart all
```

### Issue: SSL certificate error
```bash
# Renew certificate
sudo certbot renew --force-renewal -d workroot.in -d www.workroot.in

# Reload nginx
sudo systemctl reload nginx
```

### Issue: 404 errors on assets
```bash
# Check dist directory exists
ls -la dist/

# Rebuild
npm run build
pm2 restart workroot-website
```

### Issue: Redirects not working
```bash
# Verify nginx config
sudo nginx -t

# Check redirect rules
sudo cat /etc/nginx/sites-available/workroot | grep -A 5 "server_name workroot.com"

# Reload nginx
sudo systemctl reload nginx
```

---

## 📞 Emergency Contacts

- **Technical Lead**: [CONTACT]
- **DevOps Team**: [CONTACT]
- **On-Call Engineer**: [CONTACT]

---

## 📋 Full Documentation

- **Complete Checklist**: `DOMAIN-MIGRATION-CHECKLIST.md`
- **Migration Summary**: `MIGRATION-SUMMARY.md`
- **Deployment Guide**: `DEPLOYMENT.md`

---

**Last Updated**: 2026-03-21
