5.6 KiB
5.6 KiB
V2-Docker Operations Guide
Deployment
Prerequisites
- Docker and Docker Compose
- PostgreSQL 13+
- Python 3.8+
- Minimum 4GB RAM
- 20GB disk space
Initial Setup
# Clone repository
git clone <repository-url>
cd v2-Docker
# Set environment variables
cp .env.example .env
# Edit .env with your configuration
# Start services
docker-compose up -d
# Run database migrations
docker exec v2_adminpanel python manage.py migrate
Service Configuration
License Server
v2_lizenzserver:
image: v2_lizenzserver:latest
environment:
- DATABASE_URL=postgresql://user:pass@db:5432/v2
- JWT_SECRET=${JWT_SECRET}
- API_KEY=${API_KEY}
ports:
- "8080:8080"
Admin Panel
v2_adminpanel:
image: v2_adminpanel:latest
environment:
- DATABASE_URL=postgresql://user:pass@db:5432/v2
- SECRET_KEY=${SECRET_KEY}
ports:
- "5000:5000"
Monitoring
Prometheus Configuration
Scrape Configs
scrape_configs:
- job_name: 'license-server'
static_configs:
- targets: ['v2_lizenzserver:8080']
- job_name: 'postgres'
static_configs:
- targets: ['postgres_exporter:9187']
Alert Rules
- License server down:
up{job="license-server"} == 0 - High error rate:
rate(http_requests_total{status=~"5.."}[5m]) > 0.05 - Database connections:
pg_stat_database_numbackends > 100
Grafana Dashboards
-
System Overview Dashboard
- CPU and memory usage
- Network traffic
- Disk usage
- Container status
-
License Server Dashboard
- Active licenses
- Heartbeat frequency
- API response times
- Error rates
-
Database Performance Dashboard
- Query performance
- Connection pool status
- Table sizes
- Slow queries
Accessing Monitoring
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3001 (admin/admin)
- Alertmanager: http://localhost:9093
Maintenance
Database Maintenance
Partition Management
-- Check existing partitions
SELECT tablename FROM pg_tables
WHERE tablename LIKE 'license_heartbeats_%'
ORDER BY tablename;
-- Create future partitions manually
CALL create_monthly_partitions('license_heartbeats', 3);
-- Drop old partitions
DROP TABLE IF EXISTS license_heartbeats_2024_01;
Backup Procedures
# Full database backup
docker exec v2_db pg_dump -U postgres v2 > backup_$(date +%Y%m%d).sql
# Backup specific tables
docker exec v2_db pg_dump -U postgres -t licenses -t license_activations v2 > licenses_backup.sql
# Restore from backup
docker exec -i v2_db psql -U postgres v2 < backup_20250619.sql
Log Management
Log Locations
- License Server:
/var/log/license-server/ - Admin Panel:
/var/log/adminpanel/ - Nginx:
/var/log/nginx/
Log Rotation
# Configure logrotate
/var/log/license-server/*.log {
daily
rotate 7
compress
delaycompress
notifempty
create 0640 www-data www-data
}
Performance Optimization
Database Tuning
-- Update statistics
ANALYZE;
-- Reindex tables
REINDEX TABLE licenses;
REINDEX TABLE license_activations;
-- Vacuum tables
VACUUM ANALYZE licenses;
Resource Limits
# Docker resource constraints
services:
v2_lizenzserver:
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '1'
memory: 1G
Troubleshooting
Common Issues
License Server Not Responding
- Check container status:
docker ps - View logs:
docker logs v2_lizenzserver - Test database connection:
docker exec v2_lizenzserver pg_isready - Verify JWT_SECRET is set
Database Connection Issues
- Check PostgreSQL status:
docker exec v2_db pg_isready - Verify credentials in .env
- Check network connectivity:
docker network ls - Review PostgreSQL logs:
docker logs v2_db
High Memory Usage
- Check container stats:
docker stats - Review memory limits in docker-compose.yml
- Analyze database queries for optimization
- Consider scaling horizontally
Health Checks
# License server health
curl http://localhost:8080/health
# Database health
docker exec v2_db pg_isready
# Admin panel health
curl http://localhost:5000/health
# Monitoring stack
curl http://localhost:9090/-/healthy # Prometheus
curl http://localhost:3001/api/health # Grafana
Security Considerations
API Security
- Use strong JWT_SECRET (minimum 32 characters)
- Rotate API keys regularly
- Implement rate limiting
- Use HTTPS in production
Database Security
- Use strong passwords
- Limit database access
- Enable SSL for connections
- Regular security updates
Container Security
- Use official base images
- Scan images for vulnerabilities
- Don't run containers as root
- Keep Docker updated
Scaling Strategies
Horizontal Scaling
# Scale license server
docker-compose up -d --scale v2_lizenzserver=3
# Load balancing with Nginx
upstream license_servers {
server v2_lizenzserver_1:8080;
server v2_lizenzserver_2:8080;
server v2_lizenzserver_3:8080;
}
Database Scaling
- Read replicas for reporting
- Connection pooling
- Query optimization
- Partitioning for large tables
Disaster Recovery
Backup Strategy
- Daily automated backups
- Off-site backup storage
- Test restore procedures
- Document recovery steps
High Availability
- Database replication
- Service redundancy
- Load balancing
- Automated failover
Monitoring Best Practices
- Set up alerts for critical metrics
- Create runbooks for common issues
- Regular review of dashboards
- Capacity planning based on trends
- Document all custom configurations