docs: add quick backend deployment checklist
Simple step-by-step guide to deploy backend to nexus-vector: 1. SSH to nexus-vector 2. Create deployment directory 3. Clone repository 4. Set up SSL certificates (Let's Encrypt) 5. Create .env with secure passwords 6. Copy docker-compose.prod.yml 7. Build and start services 8. Run database migrations 9. Verify with curl Includes: - Secure password generation commands - Troubleshooting section - Common Docker commands - Deployment checklist - Success criteria - Notes about first-time deployment Use this to quickly get the backend running! Job ID: MTAD-IMPL-2025-11-18-CL
This commit is contained in:
parent
dd26500419
commit
cb4431eade
1 changed files with 275 additions and 0 deletions
275
QUICK_DEPLOYMENT_CHECKLIST.md
Normal file
275
QUICK_DEPLOYMENT_CHECKLIST.md
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
# Quick Backend Deployment Checklist
|
||||
|
||||
**Problem**: Getting 404 at mtd.runfoo.run
|
||||
**Cause**: Backend not deployed yet
|
||||
**Solution**: Deploy now using these steps
|
||||
|
||||
---
|
||||
|
||||
## ✅ QUICK DEPLOYMENT (30 minutes)
|
||||
|
||||
### Step 1: SSH to nexus-vector
|
||||
|
||||
```bash
|
||||
ssh admin@nexus-vector
|
||||
```
|
||||
|
||||
### Step 2: Create deployment directory
|
||||
|
||||
```bash
|
||||
sudo mkdir -p /srv/containers/mtad-api
|
||||
cd /srv/containers/mtad-api
|
||||
```
|
||||
|
||||
### Step 3: Clone the repository
|
||||
|
||||
```bash
|
||||
# Clone the hub
|
||||
git clone https://github.com/fullsizemalt/morethanadiagnosis-hub.git .
|
||||
|
||||
# Go to backend
|
||||
cd backend
|
||||
```
|
||||
|
||||
### Step 4: Set up SSL certificates (Let's Encrypt)
|
||||
|
||||
```bash
|
||||
# Install certbot
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y certbot
|
||||
|
||||
# Create certificates
|
||||
sudo certbot certonly --standalone \
|
||||
-d mtd.runfoo.run \
|
||||
--agree-tos \
|
||||
--email admin@morethanadiagnosis.com
|
||||
|
||||
# Copy to local directory
|
||||
sudo mkdir -p /srv/containers/mtad-api/certbot/conf
|
||||
sudo cp -r /etc/letsencrypt /srv/containers/mtad-api/certbot/conf/
|
||||
sudo chown -R admin:admin /srv/containers/mtad-api/certbot/
|
||||
```
|
||||
|
||||
### Step 5: Create .env file
|
||||
|
||||
```bash
|
||||
cat > .env << 'EOF'
|
||||
# Database
|
||||
DB_USER=admin
|
||||
DB_PASSWORD=your_secure_password_here
|
||||
|
||||
# Redis
|
||||
REDIS_PASSWORD=your_redis_password_here
|
||||
|
||||
# Security
|
||||
SECRET_KEY=your_secret_key_here
|
||||
|
||||
# Other settings
|
||||
ENV=production
|
||||
DEBUG=false
|
||||
CORS_ORIGINS=["https://mtd.runfoo.run"]
|
||||
EOF
|
||||
```
|
||||
|
||||
**Generate secure passwords**:
|
||||
```bash
|
||||
# For DB_PASSWORD
|
||||
openssl rand -base64 24
|
||||
|
||||
# For REDIS_PASSWORD
|
||||
openssl rand -base64 24
|
||||
|
||||
# For SECRET_KEY
|
||||
openssl rand -hex 32
|
||||
```
|
||||
|
||||
### Step 6: Copy production docker-compose
|
||||
|
||||
```bash
|
||||
cp docker-compose.prod.yml docker-compose.yml
|
||||
```
|
||||
|
||||
### Step 7: Build and start
|
||||
|
||||
```bash
|
||||
# Build images
|
||||
docker-compose build
|
||||
|
||||
# Start all services
|
||||
docker-compose up -d
|
||||
|
||||
# Wait for startup
|
||||
sleep 10
|
||||
|
||||
# Check status
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
**Expected output**:
|
||||
```
|
||||
NAME STATUS
|
||||
mtad-postgres Up (healthy)
|
||||
mtad-redis Up (healthy)
|
||||
mtad-api Up (healthy)
|
||||
mtad-nginx Up
|
||||
```
|
||||
|
||||
### Step 8: Run database migrations
|
||||
|
||||
```bash
|
||||
# Enter API container
|
||||
docker-compose exec api bash
|
||||
|
||||
# Inside container:
|
||||
cd /app
|
||||
alembic upgrade head
|
||||
|
||||
# Exit container
|
||||
exit
|
||||
```
|
||||
|
||||
### Step 9: Verify deployment
|
||||
|
||||
```bash
|
||||
# Health check
|
||||
curl https://mtd.runfoo.run/health
|
||||
|
||||
# API check
|
||||
curl https://mtd.runfoo.run/api/v1/health
|
||||
|
||||
# Should return 200 OK with JSON response
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔍 TROUBLESHOOTING
|
||||
|
||||
### Still getting 404?
|
||||
|
||||
**Check if backend is running**:
|
||||
```bash
|
||||
docker-compose ps
|
||||
```
|
||||
|
||||
**If services not running**:
|
||||
```bash
|
||||
docker-compose logs
|
||||
# Check for errors
|
||||
```
|
||||
|
||||
**Restart services**:
|
||||
```bash
|
||||
docker-compose restart
|
||||
```
|
||||
|
||||
**Check if Nginx is running**:
|
||||
```bash
|
||||
docker-compose logs nginx
|
||||
# Should show nginx starting
|
||||
```
|
||||
|
||||
**Check if API is responding**:
|
||||
```bash
|
||||
curl -I http://localhost:8000/health
|
||||
# Should return 200 OK
|
||||
```
|
||||
|
||||
### Certificate issues?
|
||||
|
||||
```bash
|
||||
# Check certificate
|
||||
sudo openssl x509 -in /etc/letsencrypt/live/mtd.runfoo.run/fullchain.pem -text -noout
|
||||
|
||||
# Renew if needed
|
||||
sudo certbot renew --force-renewal
|
||||
```
|
||||
|
||||
### Port conflicts?
|
||||
|
||||
```bash
|
||||
# Check what's using ports
|
||||
sudo netstat -tlnp | grep :80
|
||||
sudo netstat -tlnp | grep :443
|
||||
sudo netstat -tlnp | grep :8000
|
||||
|
||||
# Kill if needed
|
||||
sudo kill -9 <PID>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 DEPLOYMENT CHECKLIST
|
||||
|
||||
- [ ] SSH to nexus-vector
|
||||
- [ ] Create `/srv/containers/mtad-api` directory
|
||||
- [ ] Clone repository
|
||||
- [ ] Set up SSL certificates (Let's Encrypt)
|
||||
- [ ] Create `.env` file with secure passwords
|
||||
- [ ] Copy `docker-compose.prod.yml` to `docker-compose.yml`
|
||||
- [ ] Build Docker images: `docker-compose build`
|
||||
- [ ] Start services: `docker-compose up -d`
|
||||
- [ ] Verify all containers healthy: `docker-compose ps`
|
||||
- [ ] Run migrations: `docker-compose exec api alembic upgrade head`
|
||||
- [ ] Test health endpoint: `curl https://mtd.runfoo.run/health`
|
||||
- [ ] Test API endpoint: `curl https://mtd.runfoo.run/api/v1/health`
|
||||
- [ ] Check browser: https://mtd.runfoo.run (should show API)
|
||||
|
||||
---
|
||||
|
||||
## 🚀 SUCCESS = When
|
||||
|
||||
✅ `curl https://mtd.runfoo.run/health` returns `{"status":"healthy",...}`
|
||||
✅ `curl https://mtd.runfoo.run/api/v1/health` returns API response
|
||||
✅ Browser shows API information (no 404)
|
||||
✅ All docker containers show "healthy"
|
||||
|
||||
---
|
||||
|
||||
## 📞 COMMON COMMANDS
|
||||
|
||||
```bash
|
||||
# View logs
|
||||
docker-compose logs -f
|
||||
|
||||
# Check specific service
|
||||
docker-compose logs api
|
||||
|
||||
# Restart specific service
|
||||
docker-compose restart api
|
||||
|
||||
# Restart everything
|
||||
docker-compose down && docker-compose up -d
|
||||
|
||||
# Check resource usage
|
||||
docker stats
|
||||
|
||||
# SSH into container
|
||||
docker-compose exec api bash
|
||||
|
||||
# Run migrations
|
||||
docker-compose exec api alembic upgrade head
|
||||
|
||||
# Check database
|
||||
docker-compose exec postgres psql -U admin -d morethanadiagnosis -c "SELECT 1"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 💡 QUICK NOTES
|
||||
|
||||
- First time deployment takes ~5-10 minutes for all images to build
|
||||
- DNS may need 24-48 hours to fully propagate (but should work now with 216.158.230.94)
|
||||
- Certificates auto-renew every 90 days
|
||||
- Backups run daily at 2 AM (if cron configured)
|
||||
- All data persists in Docker volumes even after restart
|
||||
|
||||
---
|
||||
|
||||
**Next Step**: Follow the 9 steps above to deploy the backend!
|
||||
|
||||
Once running, you should see the API responding at:
|
||||
- Health: https://mtd.runfoo.run/health
|
||||
- API Docs: https://mtd.runfoo.run/docs
|
||||
- ReDoc: https://mtd.runfoo.run/redoc
|
||||
|
||||
Let me know if you hit any errors!
|
||||
Loading…
Add table
Reference in a new issue