Some checks are pending
Deploy to Production / deploy (push) Waiting to run
- Changed admin frontend port from 3000 to 3300 across all configuration files - Changed API backend port from 3001 to 3301 across all configuration files - Updated health check endpoints to use new ports in CI/CD workflow - Modified documentation and deployment guides to reflect new port numbers - Updated Caddy and Nginx reverse proxy configurations to use new ports
8.9 KiB
8.9 KiB
VoxBlog Production Deployment - Complete Setup
🎉 What's Been Created
Your VoxBlog project is now production-ready with a complete CI/CD pipeline!
Files Created
voxblog/
├── docker/
│ ├── api.Dockerfile ✅ Backend Docker image
│ ├── admin.Dockerfile ✅ Frontend Docker image
│ └── nginx.conf ✅ Nginx config for frontend
├── .gitea/
│ └── workflows/
│ └── deploy.yml ✅ Gitea Actions CI/CD workflow
├── docker-compose.yml ✅ Multi-container orchestration
├── deploy.sh ✅ Deployment script (executable)
├── .dockerignore ✅ Docker build optimization
├── .env.example ✅ Updated with all variables
├── DEPLOYMENT_GUIDE.md ✅ Complete deployment documentation
└── QUICK_START.md ✅ 5-minute setup guide
🏗️ Architecture
┌─────────────────────────────────────────────────────────┐
│ Your VPS Server │
│ │
│ ┌────────────┐ ┌──────────────┐ ┌─────────────┐ │
│ │ Gitea │→ │ Gitea Runner │→ │ Docker │ │
│ │ Repository │ │ (CI/CD) │ │ Containers │ │
│ └────────────┘ └──────────────┘ └─────────────┘ │
│ ↓ │
│ ┌────────────────────────┐ │
│ │ voxblog-api:3301 │ │
│ │ voxblog-admin:3300 │ │
│ │ mysql:3306 │ │
│ └────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
🚀 Deployment Options
Option 1: Gitea Actions (Recommended)
Pros:
- ✅ Fully automated
- ✅ Built-in to Gitea
- ✅ GitHub Actions compatible
- ✅ Detailed logs and status
- ✅ Secrets management
Setup:
- Install Gitea Runner on VPS
- Add secrets to Gitea repository
- Push to main → auto-deploy!
Option 2: Webhook + Script
Pros:
- ✅ Simple and lightweight
- ✅ No additional services needed
- ✅ Direct script execution
- ✅ Easy to debug
Setup:
- Install webhook listener
- Configure Gitea webhook
- Push to main → webhook triggers deploy.sh
Option 3: Manual Deployment
Pros:
- ✅ Full control
- ✅ No setup required
- ✅ Good for testing
Usage:
ssh user@vps
cd /path/to/voxblog
./deploy.sh
📋 Deployment Workflow
Developer commits code
↓
Push to main branch
↓
Gitea detects push
↓
┌─────────────────────────────┐
│ Gitea Actions / Webhook │
│ triggers deployment │
└─────────────────────────────┘
↓
┌─────────────────────────────┐
│ deploy.sh executes: │
│ 1. Pull latest code │
│ 2. Build Docker images │
│ 3. Stop old containers │
│ 4. Start new containers │
│ 5. Run DB migrations │
│ 6. Health checks │
│ 7. Clean up old images │
└─────────────────────────────┘
↓
✅ Deployment Complete!
🎯 Quick Start (5 Minutes)
1. On Your VPS
# Clone repository
git clone https://your-gitea-url/username/voxblog.git
cd voxblog
# Configure environment
cp .env.example .env
nano .env # Fill in your values
# Deploy!
./deploy.sh
2. Set Up CI/CD
For Gitea Actions:
# Install runner
wget https://dl.gitea.com/act_runner/latest/act_runner-latest-linux-amd64
chmod +x act_runner-latest-linux-amd64
sudo mv act_runner-latest-linux-amd64 /usr/local/bin/act_runner
# Register and start
act_runner register --instance https://your-gitea --token YOUR_TOKEN
# Then set up as systemd service (see QUICK_START.md)
For Webhook:
sudo apt-get install webhook
# Configure webhook (see QUICK_START.md)
3. Add Secrets (Gitea Actions only)
Repository → Settings → Secrets → Add all from .env
4. Push to Main
git add .
git commit -m "Add deployment configuration"
git push origin main
🎉 Auto-deployment triggered!
🔧 Environment Variables
All required variables in .env:
# Database
MYSQL_ROOT_PASSWORD=strong_password
MYSQL_PASSWORD=voxblog_password
# Application
ADMIN_PASSWORD=admin_password
OPENAI_API_KEY=sk-...
GHOST_ADMIN_API_KEY=...
# S3 Storage
S3_BUCKET=your-bucket
S3_REGION=us-east-1
S3_ACCESS_KEY=...
S3_SECRET_KEY=...
S3_ENDPOINT=https://s3.amazonaws.com
# Frontend
VITE_API_URL=https://api.yourdomain.com
🌐 Production Setup
With Domain Name
-
Point DNS to VPS
A Record: @ → your-vps-ip A Record: api → your-vps-ip -
Install Nginx
sudo apt-get install nginx # Configure (see QUICK_START.md) -
Add SSL
sudo certbot --nginx -d yourdomain.com
Without Domain (IP Only)
Access directly:
- Admin:
http://your-vps-ip:3300 - API:
http://your-vps-ip:3301
📊 Monitoring & Maintenance
View Logs
docker-compose logs -f
docker-compose logs -f api
docker-compose logs -f admin
Check Status
docker-compose ps
docker ps
Restart Services
docker-compose restart
docker-compose restart api
Backup Database
docker-compose exec mysql mysqldump -u voxblog -p voxblog > backup.sql
Clean Up
docker system prune -a
docker volume prune
🔐 Security Best Practices
- ✅ Use strong passwords in
.env - ✅ Never commit
.envto git (already in .gitignore) - ✅ Enable firewall:
sudo ufw enable - ✅ Use SSL/TLS (HTTPS)
- ✅ Keep Docker updated
- ✅ Regular backups
- ✅ Monitor logs for suspicious activity
- ✅ Use SSH keys instead of passwords
🐛 Troubleshooting
Deployment Failed
# Check logs
docker-compose logs
# Check specific service
docker-compose logs api
# Restart
docker-compose restart
Port Already in Use
# Find process
sudo lsof -i :3301
sudo lsof -i :3300
# Kill process
sudo kill -9 <PID>
Out of Disk Space
# Check usage
docker system df
# Clean up
docker system prune -a
docker volume prune
Database Connection Failed
# Check MySQL
docker-compose exec mysql mysql -u voxblog -p
# Check environment variables
docker-compose exec api env | grep DATABASE
📚 Documentation
- DEPLOYMENT_GUIDE.md - Complete deployment guide
- QUICK_START.md - 5-minute setup
- REFACTORING_SUMMARY.md - API refactoring details
- STREAMING_GUIDE.md - AI streaming implementation
🎯 Next Steps
-
Test Locally First
docker-compose up --build -
Deploy to VPS
./deploy.sh -
Set Up CI/CD
- Choose Gitea Actions or Webhook
- Configure secrets
- Test auto-deployment
-
Configure Domain & SSL
- Point DNS
- Install Nginx
- Get SSL certificate
-
Set Up Monitoring
- Configure log rotation
- Set up uptime monitoring
- Configure backups
-
Go Live! 🚀
✅ Production Readiness Checklist
- Docker files created
- docker-compose.yml configured
- .env file filled with production values
- deploy.sh tested locally
- CI/CD pipeline chosen and configured
- Secrets added to Gitea (if using Actions)
- Domain DNS configured (optional)
- Nginx reverse proxy set up (optional)
- SSL certificate installed (optional)
- Firewall configured
- Backup strategy in place
- Test deployment successful
- Health checks passing
- Logs accessible and monitored
🎉 You're Ready!
Your VoxBlog project is now production-ready with:
- ✅ Dockerized backend and frontend
- ✅ Automated CI/CD pipeline
- ✅ Database with migrations
- ✅ Health checks
- ✅ Easy rollback
- ✅ Comprehensive documentation
Push to main and watch it deploy automatically! 🚀
Questions? Check the documentation or review the logs: docker-compose logs -f