5.0 KiB
5.0 KiB
Production Deployment Guide
Overview
This project uses a Blue-Green deployment strategy with automatic rollback capabilities to ensure zero-downtime deployments and quick recovery from failures.
Architecture
Blue-Green Deployment
- Blue Service: Currently serving production traffic
- Green Service: New deployment being tested
- Traffic Switch: Instant switchover via Traefik labels
- Automatic Rollback: Health check failures trigger immediate rollback
Key Features
- ✅ Zero-downtime deployments
- ✅ Automatic health checks
- ✅ Instant rollback on failure
- ✅ Backup system with retention
- ✅ Build verification before traffic switch
- ✅ Resource limits and security
Deployment Process
Automatic Deployment (Recommended)
-
Create Release Tag:
git tag 1.0.1-release git push origin 1.0.1-release -
Monitor Progress:
- GitHub Actions:
https://github.com/sotoontech/Vitron-Front/actions - Server logs:
ssh root@prod-server 'docker-compose -f /opt/front-prod/Vitron-Front/docker-compose.yml logs -f'
- GitHub Actions:
Deployment Steps (Automatic)
- Backup: Current deployment tagged as backup
- Build: New version built in parallel (green/blue)
- Health Check: 10 attempts over 100 seconds
- Traffic Switch: Instant switchover via Traefik
- Verification: Final check on live domain
- Cleanup: Old deployment stopped and cleaned
Manual Operations
Emergency Rollback
# SSH to production server
ssh root@prod-server
# Go to project directory
cd /opt/front-prod/Vitron-Front
# Rollback to latest backup
./scripts/rollback.sh
# Or rollback to specific backup
./scripts/rollback.sh vitron-frontend-backup:20240906_150230
Check Status
# Check running containers
docker ps | grep vitron
# Check available backups
docker images | grep vitron-frontend-backup
# Check service health
docker exec vitron-frontend-blue wget --spider http://localhost:3000/
curl -I https://vitrown.com/
# Check logs
docker-compose logs -f vitron-frontend-blue
docker-compose logs -f vitron-frontend-green
Manual Deployment
# SSH to server
ssh root@prod-server
cd /opt/front-prod/Vitron-Front
# Pull latest changes
git fetch --all
git checkout main
git pull origin main
# Deploy manually
docker-compose -f docker-compose.yml up -d --build
Environment Configuration
Required GitHub Secrets
PROD_SSH_HOST: Production server IP/hostnamePROD_SSH_KEY: SSH private key for server accessPROD_REMIX_SECRET: Strong random string for session encryption
Environment Variables
NODE_ENV=production
VITE_API_BASE_URL=https://api.prod.vitrown.com
VITE_API_SOCKET_BASE_URL=wss://api.prod.vitrown.com
VITE_API_URL=https://api.prod.vitrown.com
VITE_SITE_URL=https://vitrown.com
VITE_DOMAIN_URL=https://vitrown.com
VITE_APP_VERSION_TYPE=production
REMIX_SECRET=[FROM_GITHUB_SECRETS]
Troubleshooting
Common Issues
-
Build Failed
# Check build logs docker-compose logs vitron-frontend-[color] # Manual build test docker-compose build vitron-frontend-blue -
Health Check Failed
# Check container status docker exec vitron-frontend-[color] ps aux # Check internal health docker exec vitron-frontend-[color] wget --spider http://localhost:3000/ # Check logs docker exec vitron-frontend-[color] tail -f /var/log/nginx/error.log -
Rollback Issues
# List available backups docker images | grep backup # Manual container start docker run -d --name manual-rollback vitron-frontend-backup:20240906_150230
Health Check Endpoints
- Internal:
http://localhost:3000/(container health) - External:
https://vitrown.com/(public endpoint) - API:
https://api.prod.vitrown.com/api/health/(backend health)
Security Features
- Non-root user: Containers run as
remixuser (UID 1001) - Security headers: X-Frame-Options, X-Content-Type-Options, etc.
- HTTPS enforcement: Automatic redirect from HTTP
- Resource limits: Memory limits prevent resource exhaustion
- Network isolation: Services run in isolated Docker network
Monitoring
Key Metrics to Monitor
- Container health status
- Response time on health checks
- Memory usage (limit: 512MB)
- Disk space (Docker images)
- SSL certificate expiry
Log Locations
- Application logs:
docker-compose logs - Traefik logs: Check proxy network logs
- System logs:
/var/log/syslogon server
Backup Strategy
- Automatic: Every deployment creates timestamped backup
- Retention: Last 3 backups kept automatically
- Manual backup:
docker tag vitron-frontend-blue vitron-frontend-backup:manual-$(date +%Y%m%d_%H%M%S)
Performance Optimizations
- Multi-stage build: Smaller production images
- Asset optimization: Terser minification, tree shaking
- Caching: Docker layer caching, npm ci
- Resource limits: Prevents memory leaks
- Health checks: Quick failure detection