Skip to content

Deploying a ClipBucket App

ClipBucket is the premier open-source video sharing and streaming platform that empowers creators, businesses, and communities to build their own YouTube-like ecosystem. With ClipBucket, you can create a fully functional video platform supporting user-generated content, live streaming, video monetization, community engagement, advanced video management, and comprehensive analytics—all under your complete control. Whether you’re building a video sharing community, launching a professional media distribution network, creating an educational streaming service, or monetizing video content, ClipBucket provides all the tools you need to manage and distribute video content at scale while maintaining complete ownership of your data and platform.

This comprehensive guide walks through deploying ClipBucket to Klutch.sh using a Dockerfile for reliable, containerized deployment. You’ll learn how to set up ClipBucket with persistent storage for video uploads and media files, create a production-ready Dockerfile, configure the web interface, set up video encoding and processing, manage users and permissions, enable community features, implement monetization options, implement security best practices, configure custom domains, set up monitoring, and troubleshoot common issues. By the end of this guide, you’ll have a production-ready ClipBucket instance running on Klutch.sh’s global infrastructure with automatic HTTPS, optimized performance, and reliable hosting for video sharing and streaming at scale.

Prerequisites

  • Docker installed locally for testing (optional but recommended)
  • Git installed locally and a GitHub account (Klutch.sh uses GitHub as the only git source)
  • Klutch.sh account with access to the dashboard at klutch.sh/app
  • Text editor or IDE for code editing (VS Code recommended)
  • PHP knowledge (helpful but not required)
  • Basic networking knowledge: Understanding of HTTP/HTTPS and DNS
  • MySQL/MariaDB database (recommended for production use)
  • FFmpeg for video encoding and processing (included in Docker image)

Understanding ClipBucket Architecture

Technology Stack

Backend:

  • PHP 7.4+ with modern OOP architecture
  • MySQL/MariaDB database for persistent storage
  • FFmpeg for video encoding and transcoding
  • Redis (optional) for caching and session management
  • WebSocket support for real-time features

Frontend:

  • Responsive HTML5 web interface
  • JavaScript for interactive features
  • Mobile-optimized design
  • Admin dashboard for configuration

Key Features

Video Management:

  • User video uploads with chunked processing
  • Automatic video encoding and transcoding
  • Multiple video quality levels (1080p, 720p, 480p, etc.)
  • Video thumbnails and preview generation
  • Video search and categorization
  • Playlist management

User Features:

  • User registration and authentication
  • User profiles with customization
  • Subscriber/follower system
  • Private messaging
  • Video recommendations
  • Watch history and favorites

Community Features:

  • Comments and discussions
  • Video ratings and reviews
  • Sharing and social integration
  • Trending videos and categories
  • Video collections and playlists
  • User channels and subscriptions

Content Management:

  • Content moderation tools
  • Automated spam detection
  • Copyright and rights management
  • Video scheduling
  • Bulk operations and management
  • Content analytics

Monetization:

  • Advertising integration
  • Revenue sharing with creators
  • Paid content and subscriptions
  • Donation system
  • Video licensing
  • Premium features

Streaming:

  • Live streaming support
  • Adaptive bitrate streaming
  • RTMP ingest support
  • Stream quality selection
  • Recording of live streams
  • Stream analytics

Project Setup

1. Create Project Directory

Create a project directory for ClipBucket deployment:

Terminal window
mkdir clipbucket-deployment
cd clipbucket-deployment
git init

2. Create Directory Structure

Create necessary directories:

Terminal window
mkdir -p {uploads,videos,cache,backup,scripts,config}

Resulting project structure:

clipbucket-deployment/
├── Dockerfile
├── entrypoint.sh
├── config/
│ └── default.env
├── scripts/
│ └── init-db.sh
├── uploads/
│ └── (user uploaded files)
├── videos/
│ └── (encoded videos)
├── cache/
│ └── (cached data)
├── .dockerignore
├── .gitignore
└── README.md

3. Create .gitignore File

Create .gitignore to exclude unnecessary files:

.env.local
.env.*.local
*.log
*.swp
.DS_Store
.vscode
.idea
node_modules/
uploads/
videos/
cache/
backup/
tmp/
dist/
build/

4. Create .dockerignore File

Create .dockerignore to exclude files from Docker build:

.git
.gitignore
*.log
.env.local
uploads/
videos/
cache/
backup/
tmp/
.DS_Store
.vscode
.idea
.npm
coverage/
tests/

Creating a Production Dockerfile

Create a Dockerfile for production deployment:

# === Build Stage ===
FROM php:8.1-fpm-alpine AS builder
WORKDIR /app
# Install system dependencies
RUN apk add --no-cache \
build-base \
curl \
git \
libpng-dev \
libjpeg-turbo-dev \
libwebp-dev \
libxpm-dev \
freetype-dev \
ffmpeg \
imagemagick \
imagemagick-dev
# Install PHP extensions
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp && \
docker-php-ext-install -j$(nproc) \
gd \
mysqli \
pdo \
pdo_mysql \
zip \
curl \
mbstring \
exif \
imagick
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Clone and install ClipBucket
RUN git clone https://github.com/clipbucket/clipbucket.git . && \
composer install --no-dev && \
chmod -R 755 . && \
chown -R www-data:www-data .
# === Production Stage ===
FROM php:8.1-fpm-alpine
WORKDIR /app
# Install runtime dependencies
RUN apk add --no-cache \
curl \
mysql-client \
ffmpeg \
imagemagick \
libpng \
libjpeg-turbo \
libwebp \
freetype \
tini
# Install PHP extensions
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp && \
docker-php-ext-install -j$(nproc) \
gd \
mysqli \
pdo \
pdo_mysql \
zip \
curl \
mbstring \
exif \
imagick
# Copy built application from builder
COPY --from=builder /app /app
# Create app directories
RUN mkdir -p /app/uploads /app/videos /app/cache /app/logs && \
chown -R www-data:www-data /app
# Copy PHP configuration
COPY php.ini /usr/local/etc/php/conf.d/custom.ini
COPY php-fpm.conf /usr/local/etc/php-fpm.d/custom.conf
# Copy entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Use tini to handle signals properly
ENTRYPOINT ["/sbin/tini", "--"]
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:9000/ping || exit 1
# Expose port
EXPOSE 9000
# Start PHP-FPM
CMD ["php-fpm"]

Dockerfile Explanation

  • Build stage: Compiles ClipBucket from source with all PHP extensions
  • Production stage: Lightweight runtime with only production dependencies
  • Data persistence: /app/uploads for user files, /app/videos for encoded videos, /app/cache for caching
  • FFmpeg integration: Included for video encoding and processing
  • Non-root user: Runs as www-data user for security
  • Health checks: Automatic container health monitoring
  • Signal handling: Uses tini for proper signal handling
  • Multi-stage build: Reduces final image size significantly

Create PHP Configuration

Create php.ini for custom PHP settings:

; Upload and video limits
upload_max_filesize = 2G
post_max_size = 2G
max_execution_time = 3600
max_input_time = 3600
; Memory settings
memory_limit = 512M
; Display errors in development only
display_errors = Off
log_errors = On
; Enable extensions
extension = gd
extension = mysqli
extension = imagick

Create PHP-FPM Configuration

Create php-fpm.conf for PHP-FPM tuning:

[www]
listen = 9000
listen.allowed_clients = 127.0.0.1
; Process management
pm = dynamic
pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
; Timeouts
request_terminate_timeout = 3600
request_slowlog_timeout = 10s
; Logging
access.log = /proc/self/fd/2
slowlog = /proc/self/fd/2

Create Entrypoint Script

Create entrypoint.sh for initialization:

#!/bin/sh
set -e
echo "Starting ClipBucket initialization..."
# Wait for database if needed
if [ -n "$DATABASE_HOST" ]; then
echo "Waiting for database to be ready..."
timeout 30 sh -c "until nc -z $DATABASE_HOST $DATABASE_PORT; do sleep 1; done" || true
fi
# Run migrations if needed
if [ "$RUN_MIGRATIONS" = "true" ]; then
echo "Running database migrations..."
php artisan migrate || true
fi
# Set file permissions
chown -R www-data:www-data /app/uploads /app/videos /app/cache /app/logs 2>/dev/null || true
echo "ClipBucket startup complete. Starting PHP-FPM..."
# Start PHP-FPM
exec php-fpm

Building the Dockerfile Locally (Optional)

Test the Dockerfile locally:

Terminal window
# Build the Docker image
docker build -t clipbucket:latest .
# Run the container locally (for testing only)
docker run -d \
--name clipbucket-test \
-p 9000:9000 \
-e DATABASE_HOST=db.example.com \
-e DATABASE_USER=clipbucket \
-e DATABASE_PASSWORD=password \
-v clipbucket-uploads:/app/uploads \
-v clipbucket-videos:/app/videos \
clipbucket:latest
# Wait for container to start
sleep 10
# Access the application via web server
# Configure Nginx to proxy to port 9000

Setting Up Nginx Web Server

ClipBucket requires a web server (Nginx) to proxy requests to PHP-FPM. Create nginx.conf:

upstream php-fpm {
server 127.0.0.1:9000;
}
server {
listen 80;
server_name _;
root /app/public;
index index.php index.html;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
# Gzip compression
gzip on;
gzip_vary on;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss;
# PHP-FPM configuration
location ~ \.php$ {
fastcgi_pass php-fpm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 300;
}
# Static files
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Deny access to sensitive files
location ~ /\. {
deny all;
}
location ~ ~$ {
deny all;
}
}

Deploying with Docker on Klutch.sh

Klutch.sh automatically detects a Dockerfile in your repository root and uses it for deployment.

Prerequisites for Docker Deployment

  • Your ClipBucket project pushed to GitHub with Dockerfile
  • Database credentials prepared (MySQL/MariaDB recommended for production)
  • Planned storage for video uploads and encoded videos
  • Web server (Nginx) configured for PHP-FPM

Steps to Deploy with Docker

  1. Prepare Your Repository

    Commit and push all necessary files:

    Terminal window
    git add Dockerfile entrypoint.sh nginx.conf php.ini php-fpm.conf .dockerignore
    git commit -m "Add Docker deployment configuration for ClipBucket"
    git push origin main
  2. Log In to Klutch.sh Dashboard

    Go to klutch.sh/app and sign in with your GitHub account.

  3. Create a Project

    Navigate to the Projects section and create a new project for your ClipBucket instance.

  4. Create an App

    Click “Create App” and select your GitHub repository containing the ClipBucket Docker configuration.

  5. Select the Branch

    Choose the branch you want to deploy (typically main).

  6. Configure Traffic Type

    Select HTTP as the traffic type for ClipBucket (a web application).

  7. Set the Internal Port

    Set the internal port to 9000 – this is the port where PHP-FPM server listens.

  8. Add Environment Variables

    Configure environment variables for your ClipBucket instance:

    APP_ENV=production
    APP_DEBUG=false
    APP_LOG_LEVEL=error
    # Database Configuration
    DATABASE_HOST=db.example.com
    DATABASE_PORT=3306
    DATABASE_NAME=clipbucket
    DATABASE_USER=clipbucket_user
    DATABASE_PASSWORD=strong_password_here
    DATABASE_CHARSET=utf8mb4
    DATABASE_COLLATION=utf8mb4_unicode_ci
    # Application Configuration
    APP_NAME=MyClipBucket
    APP_URL=https://example-app.klutch.sh
    APP_DOMAIN=example-app.klutch.sh
    APP_SECURE=true
    # File Upload Configuration
    UPLOAD_PATH=/app/uploads
    VIDEOS_PATH=/app/videos
    MAX_UPLOAD_SIZE=2147483648
    ALLOWED_EXTENSIONS=avi,mkv,flv,wmv,mov,mp4,mpg,mpeg,3gp,webm,m3u8,ts
    # Session Configuration
    SESSION_DRIVER=file
    SESSION_LIFETIME=120
    SESSION_SECURE_COOKIES=true
    SESSION_SAME_SITE=Lax
    # Cache Configuration
    CACHE_DRIVER=file
    CACHE_TTL=3600
    # Queue Configuration
    QUEUE_CONNECTION=sync
    # Email Configuration
    MAIL_DRIVER=smtp
    MAIL_HOST=smtp.mailtrap.io
    MAIL_PORT=587
    MAIL_USERNAME=your-username
    MAIL_PASSWORD=your-password
    MAIL_FROM_ADDRESS=noreply@example.com
    MAIL_FROM_NAME=ClipBucket
    # FFmpeg Configuration
    FFMPEG_PATH=/usr/bin/ffmpeg
    FFPROBE_PATH=/usr/bin/ffprobe
    VIDEO_ENCODING_PRESET=medium
    # Security Settings
    APP_KEY=base64:change_this_to_random_key
    HASH_ALGORITHM=bcrypt
    # Feature Flags
    ENABLE_REGISTRATION=true
    ENABLE_COMMENTS=true
    ENABLE_RATINGS=true
    ENABLE_MESSAGING=true
    ENABLE_MONETIZATION=false
    ENABLE_LIVE_STREAMING=false
    RUN_MIGRATIONS=true
    TZ=UTC

    Replace with your actual values. Generate a secure APP_KEY using: php artisan key:generate

  9. Configure Persistent Storage

    ClipBucket needs persistent volumes for video uploads and encoded videos:

    1. After creating the app, go to Volumes
    2. Add volume for video uploads:
      • Mount path: /app/uploads
      • Size: 50-200 GiB (adjust based on expected uploads)
    3. Add volume for encoded videos:
      • Mount path: /app/videos
      • Size: 100-500 GiB (adjust based on video library)
    4. Add volume for cache:
      • Mount path: /app/cache
      • Size: 10-20 GiB
    5. Add volume for logs:
      • Mount path: /app/logs
      • Size: 5-10 GiB
  10. Configure Compute Resources

    Select appropriate resources:

    • Minimum: 2-4 CPU, 2-4 GB RAM (small deployments, <100 videos)
    • Recommended: 4-8 CPU, 4-8 GB RAM (medium deployments, 100-10,000 videos)
    • Large: 8-16 CPU, 8-16 GB RAM (large deployments, 10,000+ videos)

    Select region closest to your primary audience. Video encoding is CPU-intensive, so adequate CPU resources are important.

  11. Deploy

    Click “Create” to start deployment. Klutch.sh will:

    1. Build the Docker image
    2. Start the ClipBucket container
    3. Assign a public URL (e.g., example-app.klutch.sh)
    4. Configure HTTPS automatically
  12. Complete Initial Setup

    After deployment, access your ClipBucket instance:

    1. Navigate to https://example-app.klutch.sh/install
    2. Follow the installation wizard
    3. Create administrator account
    4. Configure website settings:
      • Website name and description
      • Logo and branding
      • Email settings
      • Video encoding options
    5. Configure user permissions:
      • Registration settings
      • Content moderation
      • Role-based access control
    6. Set up video encoding profiles:
      • Quality levels (1080p, 720p, 480p)
      • Bitrate settings
      • Encoding presets
    7. Configure monetization (if applicable):
      • Advertising integration
      • Revenue sharing models
    8. Invite moderators and administrators
  13. Test Functionality

    Verify all features are working:

    1. Create a test user account
    2. Upload a test video
    3. Monitor encoding process
    4. Test video playback at different qualities
    5. Test user features (comments, ratings)
    6. Verify email notifications
    7. Test admin dashboard
    8. Review video analytics

ClipBucket Features and Configuration

1. Video Management

Manage and organize user-generated video content:

Video Upload Process:

  • Chunked upload support for large files
  • Progress tracking
  • Automatic transcoding after upload
  • Multiple quality generation
  • Thumbnail generation

Video Features:

  • Title, description, tags
  • Category and playlist assignment
  • Privacy levels (public, private, unlisted)
  • Comments and ratings
  • Related video suggestions
  • Sharing to social media

Upload and manage videos:

  1. Go to Videos section
  2. Click Upload Video
  3. Select video file (supports multiple formats)
  4. Add metadata (title, description, tags)
  5. Set privacy level
  6. Configure encoding settings
  7. Monitor encoding progress
  8. Publish when ready

2. User Management

Manage platform users and permissions:

User Roles:

  • Administrator: Full system access
  • Moderator: Content moderation
  • Premium User: Enhanced features
  • Regular User: Standard features
  • Guest: View-only access

User Features:

  • User profiles with customization
  • Avatar and background images
  • Bio and social links
  • Subscriber/follower management
  • Privacy settings
  • Notification preferences

Manage users:

  1. Go to Users section
  2. Review user accounts
  3. Assign roles and permissions
  4. Monitor user activity
  5. Handle user reports
  6. Manage bans and suspensions
  7. Configure user quotas

3. Video Categories

Organize content by categories:

Category Features:

  • Custom category creation
  • Category descriptions
  • Featured videos per category
  • Subcategories support
  • Category-specific moderation
  • Category analytics

Configure categories:

  1. Go to Settings > Categories
  2. Create category structure
  3. Assign videos to categories
  4. Set category thumbnails
  5. Configure category permissions
  6. Enable/disable categories

4. Playlists and Collections

Allow users to organize videos:

Playlist Features:

  • User-created playlists
  • Public/private playlists
  • Collaborative playlists
  • Playlist recommendations
  • Embed playlists
  • Playlist analytics

Create playlists:

  1. Users can create from their dashboard
  2. Add videos to playlists
  3. Reorder videos
  4. Share playlists
  5. Collaborate with others
  6. View playlist statistics

5. Community Features

Foster engagement and community building:

Engagement Features:

  • Comments and discussions
  • Video ratings and reviews
  • Messaging between users
  • Notifications system
  • Activity feeds
  • Trending videos
  • Recommended videos

Enable community features:

  1. Go to Settings > Community
  2. Enable comments and ratings
  3. Configure moderation
  4. Set notification preferences
  5. Enable messaging
  6. Configure trending algorithm
  7. Set recommendation settings

6. Content Moderation

Manage and moderate user-generated content:

Moderation Tools:

  • Video approval system
  • Comment moderation
  • User reports
  • Automated spam detection
  • Content filtering
  • Age-appropriate content management
  • Copyright/DMCA handling

Moderate content:

  1. Go to Moderation section
  2. Review reported content
  3. Approve/reject submissions
  4. Block inappropriate content
  5. Take action on violators
  6. Configure automated filters
  7. Document moderation decisions

7. Analytics and Reporting

Track platform metrics and user behavior:

Analytics Available:

  • Video view counts
  • User engagement metrics
  • Geographic analytics
  • Device and browser analytics
  • Upload and encoding metrics
  • Search analytics
  • Revenue analytics (if monetized)

Access analytics:

  1. Go to Analytics dashboard
  2. Select date range
  3. View video performance
  4. Analyze user behavior
  5. Track encoding queue
  6. Monitor storage usage
  7. Export reports

8. Monetization

Enable revenue generation (optional):

Monetization Options:

  • Ad revenue sharing
  • Premium subscriptions
  • Video licensing
  • Pay-per-view content
  • Sponsored content
  • Donation system

Configure monetization:

  1. Go to Monetization settings
  2. Enable revenue sharing
  3. Configure ad partners
  4. Set subscription tiers
  5. Configure payment processing
  6. Create premium content
  7. Track earnings

Persistent Storage

ClipBucket requires significant persistent storage for video files:

Critical Data Directories

/app/uploads/
├── user-avatars/ (user profile images)
├── thumbnails/ (video thumbnails)
└── original/ (original uploaded videos)
/app/videos/
├── 1080p/ (1080p encoded videos)
├── 720p/ (720p encoded videos)
├── 480p/ (480p encoded videos)
├── 360p/ (360p encoded videos)
└── dash/ (DASH streaming files)
/app/cache/
└── (temporary cache files)
/app/logs/
└── (application logs)

Adding Persistent Volumes

  1. In Klutch.sh dashboard, go to your ClipBucket app
  2. Navigate to Volumes section
  3. Add volume for /app/uploads:
    • Mount path: /app/uploads
    • Size: 50-200 GiB
  4. Add volume for /app/videos:
    • Mount path: /app/videos
    • Size: 100-500 GiB
  5. Add volume for /app/cache:
    • Mount path: /app/cache
    • Size: 10-20 GiB
  6. Add volume for /app/logs:
    • Mount path: /app/logs
    • Size: 5-10 GiB

Storage Planning

Plan storage based on expected usage:

Example calculations:
- 100 videos at 5GB average = 500 GB
- 1 month of logs = 5-10 GB
- Cache and thumbnails = 20-50 GB
Total recommended: 600-700 GB minimum
Scale as platform grows

Backup Strategy

Implement regular backup routine:

#!/bin/bash
# Weekly backup script
BACKUP_DIR="/backups/clipbucket"
DATE=$(date +%Y%m%d_%H%M%S)
RETENTION_DAYS=60
# Create backup directory
mkdir -p $BACKUP_DIR
# Backup database
mysqldump -h $DATABASE_HOST -u $DATABASE_USER -p$DATABASE_PASSWORD $DATABASE_NAME | \
gzip > $BACKUP_DIR/db_$DATE.sql.gz
# Backup configuration
tar -czf $BACKUP_DIR/config_$DATE.tar.gz /app/config/ 2>/dev/null || true
# Note: Video files are typically too large to backup locally
# Consider implementing incremental backups to cloud storage
# Delete old backups
find $BACKUP_DIR -name "*.gz" -mtime +$RETENTION_DAYS -delete
# Upload to remote storage
# aws s3 sync $BACKUP_DIR s3://my-backup-bucket/clipbucket/

Security Best Practices

1. HTTPS/SSL Enforcement

Klutch.sh automatically provides HTTPS for your web interface. All traffic is encrypted by default.

2. Authentication and Authorization

Implement strong access control:

User Roles:

  • Administrator: Full system access
  • Moderator: Content moderation
  • Creator: Upload and manage videos
  • User: View and interact
  • Guest: View-only access

Configure in admin panel:

  1. Go to Settings > Users
  2. Create user accounts with appropriate roles
  3. Set password requirements
  4. Enable two-factor authentication (if available)
  5. Configure API keys and tokens
  6. Regular access audits

3. Content Security

Protect platform from malicious content:

Configuration:
- File type validation
- Malware scanning
- Video codec validation
- File size limits
- Rate limiting on uploads
- Content filtering
- DMCA compliance

4. Video Security

Protect video content:

  • Access control per video (public/private)
  • Geo-blocking (if desired)
  • Hotlink protection
  • Download restrictions
  • Watermarking support
  • DRM capabilities

5. Database Security

Secure database connections:

  • Use strong database passwords
  • Enforce SSL/TLS for database connections
  • Restrict database access to application
  • Regular database backups
  • Encryption at rest (if available)
  • Enable database audit logging

6. API Security

If enabling API access:

- Require API authentication
- Generate secure API tokens
- Set API rate limits
- Log all API access
- Restrict API permissions
- Rotate keys regularly
- Enable HTTPS for API endpoints

7. File Upload Security

Protect uploaded files:

  • Validate file types and extensions
  • Scan uploads for malware
  • Store uploads outside web root
  • Implement virus scanning
  • Restrict file access by permission
  • Set upload size limits
  • Randomize file names

Performance Optimization

1. Video Encoding Optimization

Optimize video processing:

Configuration:
- Encoding preset: medium (balance speed/quality)
- Bitrate settings per quality level
- Parallel encoding for multiple files
- Queue management
- CPU affinity for encoding processes

Environment variables for encoding:

VIDEO_ENCODING_PRESET=medium
FFMPEG_THREADS=4
VIDEO_MAX_QUALITY=1080p
VIDEO_MIN_QUALITY=360p
ENABLE_ADAPTIVE_BITRATE=true

2. Caching Strategy

Implement multi-layer caching:

Application Caching:
- Cache video metadata
- Cache user profiles
- Cache category listings
- Redis for distributed caching (optional)
- Browser cache for video manifests

3. Database Optimization

Optimize database performance:

Configuration:
- Add indexes on common queries
- Enable query caching
- Optimize table structure
- Regular maintenance (OPTIMIZE TABLE)
- Connection pooling (max 20 connections)

4. CDN Integration

Distribute video content globally:

Configuration:
- Integrate with CDN for video delivery
- Configure CDN for thumbnail delivery
- Use CDN for static assets
- Implement geo-aware routing
- Configure origin pull settings

5. Resource Monitoring

Monitor system resources:

Terminal window
# Monitor CPU usage (important for encoding)
top
# Monitor disk usage
df -h /app/uploads /app/videos
# Monitor memory usage
free -h
# Monitor encoding queue
# Check logs for encoding status
# Check container resources
docker stats container_id

Monitoring and Logging

1. Access Application Logs

View ClipBucket logs through Klutch.sh:

  1. Go to your app in Klutch.sh
  2. Click Logs
  3. Filter by time range and log level
  4. Search for specific errors

2. Configure Structured Logging

Configure logging levels:

APP_LOG_LEVEL options:
- emergency: System is unusable
- alert: Action must be taken immediately
- critical: Critical condition
- error: Error condition (default for production)
- warning: Warning condition
- notice: Normal but significant condition
- info: Informational message
- debug: Debug-level messages

3. Monitor Real-Time Metrics

Track real-time performance:

Metrics to monitor:
- Active user sessions
- Video encoding queue length
- Encoding success/failure rates
- Database connection count
- Storage usage and growth rate
- Network bandwidth
- CPU and memory utilization
- Cache hit rates

4. Health Checks

Configure health monitoring:

#!/bin/bash
# Health check script
# Check PHP-FPM endpoint
curl -f http://localhost:9000/ping || exit 1
# Check database connectivity
curl -f http://localhost:9000/health/db || exit 1
# Check critical services
curl -f http://localhost:9000/health/services || exit 1
exit 0

5. Monitoring Integration

Integrate with monitoring services:

  • Prometheus: Metrics collection
  • Grafana: Visualization dashboards
  • DataDog: Infrastructure monitoring
  • New Relic: Performance monitoring
  • Sentry: Error tracking
  • ELK Stack: Log aggregation

Custom Domains

To use a custom domain with your ClipBucket instance:

1. Add Domain in Klutch.sh

In the Klutch.sh dashboard, go to your app settings and add your custom domain (e.g., videos.example.com).

2. Update DNS Configuration

Update your DNS provider:

CNAME: videos.example.com → example-app.klutch.sh

3. Update Environment Variables

Update ClipBucket configuration:

APP_URL=https://videos.example.com
APP_DOMAIN=videos.example.com
APP_SECURE=true

Redeploy the application to apply changes.

4. Verify DNS Propagation

Check DNS resolution:

Terminal window
nslookup videos.example.com
# or
dig videos.example.com CNAME

Once propagated, your ClipBucket instance will be accessible at your custom domain with automatic HTTPS.


Troubleshooting

Issue 1: Container Won’t Start

Error: Container exits immediately or doesn’t respond

Solutions:

  • Check Docker logs: docker logs container_id
  • Verify Dockerfile builds locally: docker build -t clipbucket:test .
  • Ensure environment variables are set correctly
  • Check for missing PHP extensions
  • Verify entrypoint script has execute permissions
  • Check database connectivity

Issue 2: Cannot Access Web Interface

Error: 503 Service Unavailable or connection timeout

Solutions:

  • Verify ClipBucket is running: Check container status
  • Verify port 9000 is exposed and traffic is HTTP
  • Check firewall rules: Ensure port 9000 is accessible
  • Verify DNS resolution: dig example-app.klutch.sh
  • Check PHP-FPM is running: docker exec container_id ps aux
  • Check Nginx configuration: Proper proxy to PHP-FPM
  • Wait for initialization: Container may need time on first start

Issue 3: Video Upload Failures

Error: Uploads fail or timeout

Solutions:

  • Verify persistent volume is mounted: Check /app/uploads exists
  • Check disk space: df -h /app/uploads /app/videos
  • Verify file permissions: Container can write to uploads
  • Increase upload limits: Check MAX_UPLOAD_SIZE
  • Check timeout settings: PHP and web server timeouts
  • Review application logs for upload errors
  • Check browser console for client-side errors
  • Verify FFmpeg is available: docker exec container_id which ffmpeg

Issue 4: Video Encoding Issues

Error: Videos don’t encode or encoding fails

Solutions:

  • Verify FFmpeg is installed: docker exec container_id ffmpeg -version
  • Check encoding queue: Monitor logs for encoding process
  • Monitor CPU usage: Encoding is CPU-intensive
  • Check disk space in /app/videos
  • Verify video format is supported
  • Review FFmpeg error messages in logs
  • Increase container CPU resources
  • Check encoding timeout settings

Issue 5: Database Connection Issues

Error: “Cannot connect to database” errors

Solutions:

  • Verify database is running and accessible
  • Check DATABASE_HOST, DATABASE_PORT, credentials
  • Test database connection manually
  • Verify database user has proper permissions
  • Check firewall allows database access
  • Verify database exists and is initialized
  • Check database logs for connection issues
  • Run migrations: Ensure tables are created

Issue 6: Encoding Queue Issues

Error: Videos stuck in encoding queue

Solutions:

  • Check if encoding process is running
  • Monitor encoding logs for errors
  • Restart encoding service if needed
  • Check CPU and disk resources
  • Verify FFmpeg is functioning
  • Clear stuck jobs from queue (if possible)
  • Increase encoding concurrency
  • Check video codec compatibility

Issue 7: Storage Running Out of Space

Error: Cannot upload new videos, encoding fails

Solutions:

  • Check disk usage: du -sh /app/uploads /app/videos
  • Archive old encoded qualities
  • Delete test videos
  • Implement cleanup policies
  • Increase volume sizes
  • Consider external storage
  • Implement auto-cleanup of old files
  • Monitor storage growth

Issue 8: High CPU Usage

Error: Slow performance, high CPU usage

Solutions:

  • Monitor active encoding jobs
  • Limit concurrent encoding: FFMPEG_THREADS
  • Use lower encoding presets temporarily
  • Disable unnecessary features
  • Optimize database queries
  • Increase container CPU resources
  • Implement job queue throttling
  • Monitor third-party services

Best Practices

1. Content Management

Manage platform content effectively:

  • Review uploaded content regularly
  • Establish clear community guidelines
  • Train moderators on policies
  • Respond to user reports promptly
  • Archive completed content periodically
  • Maintain content categorization
  • Monitor trending content
  • Track popular creators

2. Video Encoding

Optimize video encoding process:

  • Monitor encoding queue length
  • Balance quality vs. encoding time
  • Use appropriate presets for content type
  • Implement parallel encoding
  • Test codec compatibility
  • Archive source videos securely
  • Track encoding metrics
  • Plan CPU scaling

3. User Engagement

Maximize user engagement:

  • Encourage content uploads
  • Feature quality content
  • Respond to community feedback
  • Implement recommendation system
  • Create engaging categories
  • Recognize top creators
  • Foster healthy discussions
  • Build community features

4. Performance Tuning

Continuously optimize performance:

  • Monitor metrics regularly
  • Optimize encoding settings
  • Cache frequently accessed content
  • Implement CDN for distribution
  • Database query optimization
  • Regular performance testing
  • Profile bottlenecks
  • Document performance baselines

5. Security Maintenance

Keep platform secure:

  • Regular security updates
  • Monitor for vulnerabilities
  • Review access logs regularly
  • Audit permission settings
  • Update dependencies regularly
  • Implement security scanning
  • Document security policies
  • Incident response planning

6. Database Maintenance

Maintain healthy database:

  • Regular backups
  • Database optimization (OPTIMIZE TABLE)
  • Monitor query performance
  • Archive old data
  • Clean up temporary data
  • Monitor database size
  • Index optimization
  • Connection pool monitoring

7. Storage Management

Manage storage efficiently:

  • Monitor storage usage
  • Implement cleanup policies
  • Compress old video files
  • Archive inactive content
  • Track storage growth
  • Plan for scaling
  • Implement retention policies
  • Document storage usage patterns

8. Backup Strategy

Implement comprehensive backups:

  • Daily database backups
  • Weekly configuration backups
  • Regular restore testing
  • Offsite backup storage
  • Document backup procedures
  • Monitor backup success
  • Document recovery procedures
  • Test disaster recovery regularly

9. Capacity Planning

Plan for platform growth:

  • Monitor growth trends
  • Plan CPU scaling
  • Plan storage scaling
  • Plan database scaling
  • Monitor bandwidth usage
  • Estimate future needs
  • Document scaling procedures
  • Budget for growth

10. Community Building

Foster healthy community:

  • Engage with users actively
  • Feature quality content
  • Celebrate achievements
  • Handle conflicts professionally
  • Maintain code of conduct
  • Build creator programs
  • Create community forums
  • Support user events

Verifying Your Deployment

After deployment completes:

  1. Check the App URL: Visit https://example-app.klutch.sh
  2. Complete Installation: Run installation wizard
  3. Create Admin Account: Set up administrator
  4. Configure Settings: Set website details
  5. Test User Registration: Create test user account
  6. Upload Test Video: Upload and monitor encoding
  7. Test Playback: View video at different qualities
  8. Test Comments: Test user engagement features
  9. Verify Storage: Confirm volumes are working
  10. Check Admin Panel: Review system health metrics

If your ClipBucket instance doesn’t work as expected, review the troubleshooting section and check the Klutch.sh dashboard logs for detailed error messages.


External Resources


Deploying ClipBucket to Klutch.sh using Docker provides a powerful, open-source video sharing and streaming platform with complete control over your video infrastructure. By following this guide, you’ve learned how to create a production-ready Dockerfile with PHP, FFmpeg, and required extensions, configure persistent storage for video files and encoded streams, set up user management and community features, configure video encoding and processing pipelines, implement content moderation tools, enable monetization options, implement security best practices, optimize performance for video delivery, configure custom domains, monitor system health, and troubleshoot common issues. Your ClipBucket instance is now running on Klutch.sh’s global infrastructure with professional-grade hosting, automatic HTTPS, scalable storage, and reliable infrastructure for managing video sharing platforms at scale. For additional help or questions, consult the official ClipBucket documentation or contact Klutch.sh support.