Deploying ChannelTube
ChannelTube is a self-hosted, privacy-focused video streaming platform that enables you to build your own YouTube-like service. It supports video uploading, streaming, playlists, comments, and subscriptions while maintaining complete control over your data. ChannelTube is ideal for content creators, educational institutions, and organizations that want to host and stream video content privately.
This guide will walk you through deploying ChannelTube on Klutch.sh, a modern cloud platform that simplifies containerized application deployment. By the end of this guide, you’ll have a fully functional ChannelTube instance running on your own domain.
Why Deploy ChannelTube on Klutch.sh?
Klutch.sh provides an excellent platform for hosting ChannelTube:
- Docker-native deployment - Klutch.sh automatically detects and deploys Dockerized applications
- Persistent storage - Attach volumes for video content, database files, and user uploads
- Custom domains - Point your domain to your ChannelTube instance
- Environment configuration - Manage secrets and configuration through the dashboard
- Zero-downtime updates - Deploy new versions of your application seamlessly
- Scalability - Easily allocate resources as your user base grows
Prerequisites
Before deploying ChannelTube on Klutch.sh, you’ll need:
- A Klutch.sh account (sign up for free)
- Access to the Klutch.sh dashboard
- A GitHub repository to store your ChannelTube deployment configuration
- A custom domain (optional but recommended for production use)
- Understanding of Docker and containerization basics
Deployment Steps
Create a Dockerfile
Create a
Dockerfilein the root of your repository to containerize ChannelTube:FROM node:20-alpine# Install system dependenciesRUN apk add --no-cache \build-base \python3 \git \ffmpeg \imagemagick# Set working directoryWORKDIR /app# Clone ChannelTube repositoryRUN git clone https://github.com/ggerganov/ChannelTube.git . && \git checkout main# Install dependenciesRUN npm install# Build the applicationRUN npm run build# Create necessary directoriesRUN mkdir -p /app/uploads /app/config# Expose portEXPOSE 3000# Health checkHEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \CMD node -e "require('http').get('http://localhost:3000/health', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"# Start the applicationCMD ["npm", "start"]Create Environment Configuration File
Create a
.env.examplefile to document required environment variables:# ChannelTube Environment Configuration# Application Host and PortNODE_ENV=productionHOST=0.0.0.0PORT=3000# Database ConfigurationDATABASE_URL=postgresql://channeltube:channeltubepass@localhost:5432/channeltubeDATABASE_HOST=dbDATABASE_PORT=5432DATABASE_USER=channeltubeDATABASE_PASSWORD=channeltubepassDATABASE_NAME=channeltube# Redis Configuration (for caching and sessions)REDIS_URL=redis://redis:6379# JWT Secret (generate with: openssl rand -base64 32)JWT_SECRET=your-jwt-secret-here-change-in-production# File Upload ConfigurationMAX_FILE_SIZE=5368709120UPLOAD_DIR=/app/uploadsTHUMBNAIL_DIR=/app/uploads/thumbnails# Video ProcessingENABLE_TRANSCODING=trueFFMPEG_PATH=/usr/bin/ffmpeg# Email Configuration (Optional)SMTP_HOST=smtp.gmail.comSMTP_PORT=587SMTP_USER=your-email@gmail.comSMTP_PASSWORD=your-app-passwordSMTP_FROM=noreply@example.com# AdministrationADMIN_EMAIL=admin@example.comADMIN_PASSWORD=change-me-in-production# API ConfigurationAPI_BASE_URL=https://example-app.klutch.shCORS_ORIGIN=https://example-app.klutch.sh# LoggingLOG_LEVEL=infoCreate Node.js Configuration File
Create a
ecosystem.config.jsfile for production process management:module.exports = {apps: [{name: 'channeltube',script: './dist/index.js',instances: 'max',exec_mode: 'cluster',env: {NODE_ENV: 'production',PORT: 3000},error_file: '/app/logs/err.log',out_file: '/app/logs/out.log',log_date_format: 'YYYY-MM-DD HH:mm:ss Z',merge_logs: true,autorestart: true,watch: false,max_memory_restart: '1G'}]};Create Database Initialization Script
Create an
init-db.shfile to set up the PostgreSQL database:#!/bin/bashset -eecho "Initializing ChannelTube database..."# Wait for PostgreSQL to be readyuntil PGPASSWORD=$DATABASE_PASSWORD psql -h "$DATABASE_HOST" -U "$DATABASE_USER" -d "postgres" -c "\q"; doecho 'Waiting for postgres...'sleep 1doneecho "PostgreSQL is ready!"# Create database if it doesn't existPGPASSWORD=$DATABASE_PASSWORD psql -h "$DATABASE_HOST" -U "$DATABASE_USER" -d "postgres" << EOFCREATE DATABASE $DATABASE_NAME;EOFecho "Database initialization complete!"# Run migrationsnpm run migrateecho "Database migrations completed!"Make it executable:
Terminal window chmod +x init-db.shCreate Docker Compose for Local Development
Create a
docker-compose.ymlfile for local development and testing (not used for Klutch.sh deployment):version: '3.8'services:channeltube:build: .container_name: channeltube-devports:- "3000:3000"environment:- NODE_ENV=development- DATABASE_URL=postgresql://channeltube:channeltubepass@db:5432/channeltube- DATABASE_HOST=db- DATABASE_USER=channeltube- DATABASE_PASSWORD=channeltubepass- DATABASE_NAME=channeltube- REDIS_URL=redis://redis:6379- JWT_SECRET=dev-secret-key-change-in-production- UPLOAD_DIR=/app/uploads- THUMBNAIL_DIR=/app/uploads/thumbnails- API_BASE_URL=http://localhost:3000- CORS_ORIGIN=http://localhost:3000- ADMIN_EMAIL=admin@localhost- ADMIN_PASSWORD=admin123depends_on:- db- redisvolumes:- ./uploads:/app/uploads- ./src:/app/srcnetworks:- channeltube-networkdb:image: postgres:16-alpinecontainer_name: channeltube-dbenvironment:- POSTGRES_USER=channeltube- POSTGRES_PASSWORD=channeltubepass- POSTGRES_DB=channeltubevolumes:- channeltube_db_data:/var/lib/postgresql/datanetworks:- channeltube-networkhealthcheck:test: ["CMD-SHELL", "pg_isready -U channeltube"]interval: 10stimeout: 5sretries: 5redis:image: redis:7-alpinecontainer_name: channeltube-redisnetworks:- channeltube-networkhealthcheck:test: ["CMD", "redis-cli", "ping"]interval: 10stimeout: 5sretries: 5volumes:channeltube_db_data:networks:channeltube-network:driver: bridgeCreate .gitignore File
Create a
.gitignorefile to exclude sensitive data from version control:# Environment files.env.env.local.env.*.local# Node.jsnode_modules/npm-debug.logyarn-error.logpackage-lock.jsonyarn.lock# Build artifactsdist/build/.next/out/# Video uploads and mediauploads/public/uploads/# Database*.sqlite*.sqlite3data/# Process managementecosystem-lock.json# IDE.vscode/.idea/*.swp*.swo*~.DS_Store# Logslogs/*.log# Cache.cache/.turbo/Push Configuration to GitHub
Push your repository to GitHub with all configuration files:
Terminal window git add Dockerfile .env.example ecosystem.config.js init-db.sh \docker-compose.yml .gitignoregit commit -m "Initial ChannelTube deployment configuration for Klutch.sh"git push origin mainDeploy on Klutch.sh
- Navigate to klutch.sh/app and log in to your dashboard
- Click Create New App
- Connect your GitHub repository containing the ChannelTube deployment files (the Dockerfile will be automatically detected)
- Configure your application settings:
- Set your preferred app name
- Review the detected Dockerfile configuration
- Select a region for deployment
- Click Deploy to start the deployment process
- Monitor the deployment progress in the dashboard
- Wait for the deployment to complete and your app to become active
Configure Environment Variables
- In your app dashboard, navigate to Environment Variables section
- Add all required variables from your
.env.examplefile:DATABASE_URL: Your PostgreSQL connection stringREDIS_URL: Your Redis connection stringJWT_SECRET: Generate a secure secret withopenssl rand -base64 32API_BASE_URL: Set tohttps://your-domain.klutch.shCORS_ORIGIN: Set tohttps://your-domain.klutch.shADMIN_EMAILandADMIN_PASSWORD: Your administrator credentials
- Click Save to apply the environment variables
- Your application will automatically restart with the new configuration
Configure Traffic Routes
- In your app dashboard, navigate to Traffic settings
- Select HTTP as the traffic type
- Set the internal port to 3000 (ChannelTube Node.js server default)
- Configure any custom domain settings if you have a domain
- Save your traffic configuration
Attach Persistent Volumes for Media Storage
ChannelTube requires persistent storage for video uploads and database files.
- In your app dashboard, navigate to Volumes settings
- Click Add Volume to create storage for video uploads:
- Enter mount path:
/app/uploads - Set volume size to 100GB or more (adjust based on expected video content)
- Click Attach to create and mount the volume
- Enter mount path:
- Click Add Volume again for database data persistence:
- Enter mount path:
/app/uploads/thumbnails - Set volume size to 10GB (for video thumbnails)
- Click Attach to create and mount the volume
- Enter mount path:
- Click Add Volume for application logs:
- Enter mount path:
/app/logs - Set volume size to 5GB
- Click Attach to create and mount the volume
- Enter mount path:
Your ChannelTube application will now be accessible at your configured domain or at
example-app.klutch.sh.
Initial Setup and Configuration
After deploying ChannelTube on Klutch.sh, complete the initial setup to prepare your video platform.
Access Your ChannelTube Instance
- Navigate to
https://example-app.klutch.shin your web browser - You’ll see the ChannelTube welcome page
- Click Admin Panel or navigate to
/admin - Log in with the admin credentials you set in environment variables
- Complete the initial setup wizard
Configure Your ChannelTube Instance
Once logged in as an administrator, configure these essential settings:
Platform Settings:
- Set your platform name and description
- Configure your site branding and logo
- Set the default video player resolution
- Configure transcoding quality options
User Management:
- Create additional administrator accounts if needed
- Set user registration policies (open or invite-only)
- Configure email verification settings
- Set up user roles and permissions
Video Processing:
- Enable or disable automatic video transcoding
- Set maximum file upload size (default: 5GB)
- Configure thumbnail generation
- Set video retention policies
Security:
- Change default admin password immediately
- Enable HTTPS (automatic with Klutch.sh)
- Configure CORS origins for API access
- Set up JWT secret rotation
Set Up Database Backups
To protect your ChannelTube data:
- In your app dashboard, navigate to Database settings
- Enable automated daily backups
- Set backup retention to at least 7 days
- Configure backup notifications to your email
Configure External Services (Optional)
Email Configuration:
- Set up SMTP for user notifications and password resets
- Configure sender email and display name
- Test email delivery
CDN Integration:
- Consider integrating a CDN for video delivery
- Configure bandwidth settings
- Set up analytics tracking
Deployment Best Practices
Performance Optimization
- Allocate sufficient resources for video transcoding (CPU-intensive)
- Use persistent volumes on high-performance storage
- Enable Redis caching for improved response times
- Configure video player to use adaptive bitrate streaming
Security Measures
- Keep ChannelTube updated to the latest version
- Regularly rotate JWT secrets
- Use strong, unique passwords for admin accounts
- Enable two-factor authentication for administrators
- Configure firewall rules to restrict access if needed
- Use HTTPS for all communications (automatic with Klutch.sh)
Monitoring and Maintenance
- Monitor disk usage for video storage volumes
- Set up alerts for deployment failures
- Review logs regularly for errors or security issues
- Schedule maintenance windows for updates
- Test backup restoration procedures monthly
Scaling Considerations
As your ChannelTube instance grows:
- Increase volume sizes proactively before running out of space
- Distribute video storage across multiple volumes if needed
- Consider load balancing for high-traffic scenarios
- Implement video caching strategies
- Use a dedicated Redis instance for better performance
Accessing ChannelTube
Once deployment is complete and configured:
- Users can access your ChannelTube instance at your configured domain
- The main interface allows browsing, searching, and watching videos
- Registered users can upload content and create channels
- Administrators access the admin panel at
/adminfor management - API endpoints are available at
/apifor third-party integrations
Troubleshooting Deployment Issues
Application Won’t Start
Check the following:
- Verify all required environment variables are set
- Ensure database connection string is correct
- Check that Redis is accessible
- Review application logs in the dashboard
Video Upload Fails
Possible solutions:
- Verify persistent volumes are properly attached
- Check available disk space on volumes
- Ensure
/app/uploadsdirectory has write permissions - Verify file upload size limit in environment variables
Database Connection Errors
Steps to resolve:
- Verify DATABASE_URL environment variable
- Ensure database is running and accessible
- Check database user credentials
- Verify network connectivity between services
Performance Issues
Optimization steps:
- Increase application memory allocation
- Enable Redis caching
- Configure video transcoding quality appropriately
- Review and optimize database queries
- Consider upgrading to higher performance storage
Advanced Configuration
Environment Variables for Customization
You can customize ChannelTube behavior with these environment variables:
# Video Quality SettingsVIDEO_QUALITY_720P=trueVIDEO_QUALITY_1080P=trueVIDEO_QUALITY_4K=false
# Cache ConfigurationCACHE_TTL=3600SESSION_TIMEOUT=86400
# API Rate LimitingRATE_LIMIT_WINDOW=900RATE_LIMIT_MAX_REQUESTS=100
# Database Connection PoolDB_POOL_MIN=2DB_POOL_MAX=10DB_IDLE_TIMEOUT=30000
# Feature FlagsENABLE_COMMENTS=trueENABLE_RECOMMENDATIONS=trueENABLE_PLAYLISTS=trueENABLE_SUBSCRIPTIONS=trueCustom Domain Setup
To use a custom domain with your ChannelTube instance:
- In your Klutch.sh dashboard, navigate to Domains
- Add your custom domain
- Follow the DNS configuration instructions
- Update your environment variables with the new domain:
API_BASE_URL=https://your-domain.comCORS_ORIGIN=https://your-domain.com
- Save and redeploy your application
Database Migration from Other Platforms
If migrating from another video platform:
- Export your video data from the source platform
- Create a migration script to transform data to ChannelTube format
- Run the migration script against your ChannelTube database
- Verify all data is correctly imported
- Update video file references if necessary
Additional Resources
Learn more about ChannelTube and Klutch.sh:
- ChannelTube GitHub Repository - Source code and contribution guidelines
- ChannelTube Documentation - Comprehensive platform documentation
- ChannelTube Issue Tracker - Report bugs and request features
- Klutch.sh Official Website - Learn more about the deployment platform
- Klutch.sh Documentation - Platform guides and API reference
Conclusion
You now have a fully functional ChannelTube instance running on Klutch.sh! Your self-hosted video streaming platform is ready to handle video uploads, streaming, and user engagement.
With the robust infrastructure provided by Klutch.sh and the flexibility of ChannelTube, you have complete control over your video content and user data. Remember to:
- Keep your application updated with the latest ChannelTube releases
- Monitor system performance and storage usage regularly
- Maintain regular backups of your database and video content
- Follow security best practices for user authentication
- Scale your infrastructure as your user base grows
For additional support or questions about deploying ChannelTube on Klutch.sh, refer to the documentation and community resources linked above.