This guide covers deploying Livetran using Docker (recommended) or running it locally. We’ll cover environment configuration, TLS certificates, and production best practices.Documentation Index
Fetch the complete documentation index at: https://docs.livetran.vijayvenkatj.in/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before deploying Livetran, ensure you have:- Docker (for containerized deployment) or Go 1.21+ (for local deployment)
- FFmpeg installed (included in Docker image)
- Cloudflare R2 account with bucket and credentials
- TLS certificates for HTTPS (self-signed for dev, valid certs for production)
- Network access to Cloudflare R2 API endpoints
Environment Configuration
Livetran uses environment variables for configuration. Create a.env file in the project root:
Required Variables
Optional Variables (Metrics)
Generating Secrets
Generate secure random secrets:Cloudflare R2 Setup
-
Create an R2 Bucket:
- Log into Cloudflare Dashboard
- Navigate to R2 → Create bucket
- Choose a bucket name (e.g.,
livetran-streams)
-
Create API Token:
- Go to R2 → Manage R2 API Tokens
- Create token with read/write permissions
- Save the
Access Key IDandSecret Access Key
-
Get Account ID:
- Found in the R2 dashboard URL or account settings
-
Configure Public Access (optional):
- Set up a custom domain or use R2.dev subdomain
- Configure CORS if needed for web players
- Set
CLOUDFLARE_PUBLIC_URLto your public endpoint
TLS Certificates
Livetran requires TLS certificates for HTTPS. Place them in thekeys/ directory:
Development (Self-Signed)
Generate self-signed certificates for local testing:Production (Let’s Encrypt)
For production, use Let’s Encrypt or your CA:Docker Deployment
Docker is the recommended deployment method for production.Building the Image
- Stage 1: Builds the Go binary
- Stage 2: Creates minimal Alpine image with FFmpeg
Running the Container
Basic Run:Volume Mounts
keys/: Read-only mount for TLS certificatesoutput/: Read-write mount for HLS files (persists across restarts)
Port Configuration
The server listens on port8080 by default (HTTPS). To change the port, modify cmd/main.go or use a reverse proxy.
Local Deployment
For development or testing, you can run Livetran directly:Prerequisites
Running
:8080 (or the port specified in main.go).
Production Considerations
Reverse Proxy (Recommended)
Use nginx or Caddy as a reverse proxy for:- SSL termination (if using Let’s Encrypt)
- Rate limiting
- Request logging
- Load balancing (multiple instances)
Resource Requirements
Per Stream:- CPU: 1-2 cores (FFmpeg encoding is CPU-intensive)
- RAM: 200-500 MB
- Disk: ~50 MB per minute of stream (HLS segments)
- Network: Depends on bitrate (5 Mbps for 1080p ABR)
- CPU: 2 cores
- RAM: 2 GB
- Disk: 10 GB+ (for HLS output before R2 upload)
Monitoring
Enable OpenTelemetry metrics for production monitoring:metrics/deployment/ for sample Grafana, Prometheus, and Loki configurations.
Logging
Livetran uses structured logging withslog. Logs include:
- Request details (remote address, user agent)
- Stream lifecycle events
- Error messages with context
- Upload status
Health Checks
Currently, Livetran doesn’t expose a health check endpoint. Consider:- Adding
/healthendpoint - Monitoring stream status via
/api/status - Checking process health via Docker health checks
Backup & Recovery
- Secrets: Store
HMAC_SECRETandJWT_SECRETin secret management (e.g., HashiCorp Vault) - TLS Certificates: Backup certificate files securely
- Configuration: Version control
.env.example(without secrets) - Stream State: Currently in-memory; consider persistence for production
Scaling
Livetran is designed for horizontal scaling:- Each instance manages its own streams
- Use a load balancer to distribute API requests
- Streams are isolated per instance
- Consider a shared state store for multi-instance deployments
Troubleshooting
”Load .ENV error”
- Cause:
.envfile not found or not readable - Solution: Ensure
.envexists in project root or use environment variables
”HMAC Secret not set in Env”
- Cause:
HMAC_SECRETenvironment variable missing - Solution: Set
HMAC_SECRETin.envor environment
”Failed to initialise secrets”
- Cause: R2 credentials missing or invalid
- Solution: Verify
R2_ACCOUNT_ID,R2_ACCESS_KEY, andR2_SECRET_KEYare set
”Failed to create upload directory”
- Cause: Insufficient permissions or disk space
- Solution: Check directory permissions and available disk space
Port Already in Use
- Cause: Another process is using port 8080
- Solution: Change port in
main.goor stop conflicting service
TLS Certificate Errors
- Cause: Invalid or missing certificates
- Solution: Verify certificates exist in
keys/and are valid
Security Checklist
- Use strong, randomly generated secrets (32+ characters)
- Enable HTTPS with valid TLS certificates
- Restrict network access (firewall rules)
- Use reverse proxy for rate limiting
- Store secrets in secret management system
- Regularly rotate
HMAC_SECRETandJWT_SECRET - Monitor logs for suspicious activity
- Keep dependencies updated (
go mod tidy) - Use read-only mounts for certificates
- Implement backup strategy for configuration
Next Steps
- Configure Authentication for API security
- Set up Ingestion for SRT connections
- Configure Uploading for R2 integration
- Review API Reference for endpoint details