This guide walks through the process of deploying the Cyber Training Platform in a production environment.
- Python 3.7+
- VirtualBox 7.0+
- PostgreSQL 13+
- Minimum 16GB RAM recommended for production
- 100GB+ storage space
- Linux server (recommended) or Windows Server
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install required system dependencies
sudo apt install -y python3-pip python3-venv postgresql nginx# Create production database
sudo -u postgres createdb cyberlab_prod
sudo -u postgres createuser cyberlab_user
# Set up database password (make sure to use a strong password)
sudo -u postgres psql
postgres=# ALTER USER cyberlab_user WITH PASSWORD 'your_secure_password';
postgres=# GRANT ALL PRIVILEGES ON DATABASE cyberlab_prod TO cyberlab_user;# Clone the repository
git clone https://github.com/your-org/cyber-training-platform.git
cd cyber-training-platform
# Set up virtual environment
python3 -m venv venv
source venv/bin/activate
# Install production dependencies
pip install -r requirements.txt
# Configure environment variables
cp example.env .env
# Edit .env with production settings# Run database migrations
alembic upgrade headCreate a systemd service file for the application:
# /etc/systemd/system/cyberlab.service
[Unit]
Description=Cyber Training Platform
After=network.target
[Service]
User=cyberlab
Group=cyberlab
WorkingDirectory=/path/to/cyber-training-platform
Environment="PATH=/path/to/cyber-training-platform/venv/bin"
ExecStart=/path/to/cyber-training-platform/venv/bin/gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
[Install]
WantedBy=multi-user.target# /etc/nginx/sites-available/cyberlab
server {
server_name your-domain.com;
location / {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}# Install certbot
sudo apt install certbot python3-certbot-nginx
# Obtain SSL certificate
sudo certbot --nginx -d your-domain.com# Start and enable services
sudo systemctl start cyberlab
sudo systemctl enable cyberlab
sudo systemctl restart nginx-
Firewall Configuration
- Configure UFW or iptables to allow only necessary ports
- Enable rate limiting for API endpoints
-
VM Network Isolation
- Ensure proper VLAN configuration
- Set up network policies for lab environments
-
Monitoring
- Set up log rotation
- Configure monitoring tools (e.g., Prometheus + Grafana)
- Enable error reporting
-
Database Backups
# Set up daily backups pg_dump cyberlab_prod > backup_$(date +%Y%m%d).sql
-
VM Template Backups
- Regular backups of VM templates
- Automated snapshot management
Common issues and their solutions:
-
Database Connection Issues
- Check PostgreSQL logs
- Verify connection strings
- Ensure proper permissions
-
VM Management Issues
- Check VirtualBox logs
- Verify VirtualBox permissions
- Check resource availability
-
Performance Issues
- Monitor system resources
- Check nginx access logs
- Review database query performance
-
Regular Updates
# Update system packages sudo apt update && sudo apt upgrade -y # Update Python packages pip install -r requirements.txt --upgrade # Run database migrations alembic upgrade head
-
Health Checks
- Monitor system resources
- Check application logs
- Review security alerts
For additional support:
- Create an issue in the GitHub repository
- Contact the development team
- Check the troubleshooting guide
Remember to always test deployment procedures in a staging environment before applying to production.