Some checks are pending
CI Pipeline / Run Tests (push) Waiting to run
CI Pipeline / Lint Code (push) Waiting to run
CI Pipeline / Security Scan (push) Waiting to run
CI Pipeline / Build Docker Images (push) Blocked by required conditions
CI Pipeline / E2E Tests (push) Blocked by required conditions
4.1 KiB
4.1 KiB
Deployment Guide
Overview
This guide covers deploying the Torrent Gateway in production using Docker Compose with comprehensive monitoring.
Prerequisites
- Docker and Docker Compose installed
- SQLite3 for database operations
- FFmpeg for video transcoding (optional but recommended)
- 4GB+ RAM recommended (8GB+ for transcoding)
- 50GB+ disk space for storage
Quick Deployment
-
Build and start services:
./scripts/deploy.sh production v1.0.0
-
Verify deployment:
./scripts/health_check.sh
Manual Deployment Steps
1. Environment Setup
# Set environment variables
export DEPLOY_ENV=production
export VERSION=v1.0.0
# Create required directories
mkdir -p data/{blobs,chunks} logs backups
2. Database Initialization
# Start services to initialize database
docker-compose -f docker-compose.prod.yml up -d gateway redis
# Wait for gateway to initialize database
./scripts/health_check.sh
3. Configuration Review
Review and update configurations:
configs/prometheus.yml
- Metrics collectionconfigs/grafana/
- Dashboard settingsconfigs/loki.yml
- Log aggregationdocker-compose.prod.yml
- Service configuration
4. Start Full Stack
# Start all services including monitoring
docker-compose -f docker-compose.prod.yml up -d
# Wait for all services to be healthy
timeout 120 bash -c 'until curl -sf http://localhost:9876/api/health; do sleep 5; done'
5. Verify Deployment
# Run comprehensive health checks
./scripts/health_check.sh
# Check service logs
docker-compose -f docker-compose.prod.yml logs
Service URLs
- Gateway API: http://localhost:9876
- Admin Panel: http://localhost:9876/admin
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/admin)
- AlertManager: http://localhost:9093
Production Checklist
- SSL/TLS certificates configured
- Firewall rules configured
- Backup strategy tested
- Monitoring alerts configured
- Log rotation configured
- Storage limits set
- Resource limits configured
- Security headers enabled
Scaling
Horizontal Scaling
# Scale gateway instances
docker-compose -f docker-compose.prod.yml up -d --scale gateway=3
Resource Limits
Update docker-compose.prod.yml
:
services:
gateway:
deploy:
resources:
limits:
memory: 2G
cpus: '1.0'
SSL/TLS Setup
-
Obtain certificates:
# Using Let's Encrypt certbot certonly --standalone -d yourdomain.com
-
Update compose file:
gateway: volumes: - /etc/letsencrypt/live/yourdomain.com:/certs:ro
-
Configure reverse proxy: Add nginx or traefik for SSL termination.
Backup Strategy
- Automated backups: Cron job runs
./scripts/backup.sh
daily - Manual backup:
./scripts/backup.sh
- Retention: Keep 30 daily, 12 monthly backups
- Storage: Offsite backup recommended
Monitoring Setup
Grafana Dashboards
- Login to Grafana (admin/admin)
- Change default password
- Import provided dashboards from
configs/grafana/dashboards/
Alert Configuration
- Review
configs/alertmanager.yml
- Configure notification channels (Slack, email, etc.)
- Test alert routing
Security Hardening
- Change default passwords
- Enable firewall:
ufw allow 9876/tcp # Gateway API ufw allow 22/tcp # SSH ufw enable
- Regular updates:
# Update system packages apt update && apt upgrade -y # Update Docker images docker-compose -f docker-compose.prod.yml pull
Common Issues
Gateway Won't Start
- Check disk space:
df -h
- Check database permissions:
ls -la data/
- Review logs:
docker-compose logs gateway
Database Corruption
- Run integrity check:
sqlite3 data/metadata.db "PRAGMA integrity_check;"
- Restore from backup:
./scripts/restore.sh <timestamp>
High Memory Usage
- Check for memory leaks in logs
- Restart services:
docker-compose restart
- Scale down if necessary