initial comment

This commit is contained in:
2026-01-24 17:43:28 -05:00
commit fe40adfd38
72 changed files with 19614 additions and 0 deletions

222
deploy-r730.sh Normal file
View File

@@ -0,0 +1,222 @@
#!/bin/bash
################################################################################
# encoderPro Automated Deployment Script for Dell R730 / Unraid
################################################################################
# This script automates the entire deployment process:
# - Clones/updates from private Git
# - Optimizes config for 48-thread R730
# - Builds Docker image
# - Pushes to private registry
# - Deploys container with optimal settings
################################################################################
set -e
# =============================================================================
# CONFIGURATION - CUSTOMIZE THESE VALUES
# =============================================================================
REGISTRY="your-registry.com" # Your private Docker registry
IMAGE_NAME="encoderpro" # Image name
IMAGE_TAG="latest" # Image tag
GIT_REPO="https://your-private-git/encoderpro.git" # Your private Git repo
APP_DIR="/mnt/user/appdata/encoderpro" # Installation directory
# R730 Optimizations
MAX_WORKERS=8 # Concurrent encodes (48 threads / 6)
CPU_SLOTS=24 # CPU slots (48 threads / 2)
CPU_LIMIT="46" # Docker CPU limit (leave 2 for system)
MEMORY_LIMIT="64g" # Docker memory limit
# =============================================================================
# SCRIPT START
# =============================================================================
echo "=========================================="
echo "encoderPro Deployment Script"
echo "Target: Dell R730 (48 threads)"
echo "=========================================="
echo ""
# =============================================================================
# Step 1: Clone or Update Repository
# =============================================================================
echo "[1/9] Checking repository..."
if [ -d "$APP_DIR/.git" ]; then
echo "Repository exists, updating..."
cd "$APP_DIR"
git pull
echo "✓ Repository updated"
else
echo "Cloning repository..."
mkdir -p /mnt/user/appdata
cd /mnt/user/appdata
git clone "$GIT_REPO" encoderpro
cd encoderpro
echo "✓ Repository cloned"
fi
echo ""
# =============================================================================
# Step 2: Create Required Directories
# =============================================================================
echo "[2/9] Creating directories..."
mkdir -p "$APP_DIR/db"
mkdir -p "$APP_DIR/logs"
mkdir -p /mnt/user/temp/encoderpro-work
mkdir -p /mnt/user/archive/movies
echo "✓ Directories created:"
echo " - $APP_DIR/db"
echo " - $APP_DIR/logs"
echo " - /mnt/user/temp/encoderpro-work"
echo " - /mnt/user/archive/movies"
echo ""
# =============================================================================
# Step 3: Setup Configuration
# =============================================================================
echo "[3/9] Configuring for R730..."
if [ ! -f "$APP_DIR/config.yaml" ]; then
echo "Creating optimized config.yaml..."
cp config-cpu.yaml config.yaml
# Optimize for R730 (48 threads)
sed -i "s/max_workers: 2/max_workers: $MAX_WORKERS/" config.yaml
sed -i "s/cpu_slots: 4/cpu_slots: $CPU_SLOTS/" config.yaml
echo "✓ Config created with R730 optimizations:"
echo " - max_workers: $MAX_WORKERS (8 concurrent encodes)"
echo " - cpu_slots: $CPU_SLOTS (utilizing 48 threads)"
else
echo "Config already exists (skipping)"
fi
echo ""
# =============================================================================
# Step 4: Build Docker Image
# =============================================================================
echo "[4/9] Building Docker image..."
echo "This may take a few minutes..."
docker build -t "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}" .
echo "✓ Image built: ${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
echo ""
# =============================================================================
# Step 5: Push to Private Registry
# =============================================================================
echo "[5/9] Pushing to private registry..."
docker push "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
echo "✓ Image pushed to registry"
echo ""
# =============================================================================
# Step 6: Stop Existing Container
# =============================================================================
echo "[6/9] Checking for existing container..."
if [ "$(docker ps -aq -f name=encoderpro)" ]; then
echo "Stopping existing container..."
docker stop encoderpro 2>/dev/null || true
docker rm encoderpro 2>/dev/null || true
echo "✓ Existing container removed"
else
echo "No existing container found"
fi
echo ""
# =============================================================================
# Step 7: Deploy New Container
# =============================================================================
echo "[7/9] Deploying container..."
docker run -d \
--name encoderpro \
-e DASHBOARD_HOST=0.0.0.0 \
-e DASHBOARD_PORT=5000 \
-p 5000:5000 \
-v /mnt/user/movies:/movies:ro \
-v /mnt/user/archive/movies:/archive \
-v /mnt/user/temp/encoderpro-work:/work \
-v "$APP_DIR/config.yaml:/config/config.yaml:ro" \
-v "$APP_DIR/db:/db" \
-v "$APP_DIR/logs:/logs" \
--cpus="$CPU_LIMIT" \
--memory="$MEMORY_LIMIT" \
--restart unless-stopped \
"${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
echo "✓ Container deployed with:"
echo " - CPU limit: $CPU_LIMIT cores"
echo " - Memory limit: $MEMORY_LIMIT"
echo " - Restart policy: unless-stopped"
echo ""
# =============================================================================
# Step 8: Verify Deployment
# =============================================================================
echo "[8/9] Verifying deployment..."
sleep 5
if [ "$(docker ps -q -f name=encoderpro)" ]; then
echo "✓ Container is running"
else
echo "✗ ERROR: Container failed to start!"
echo "Check logs: docker logs encoderpro"
exit 1
fi
echo ""
# =============================================================================
# Step 9: Display Summary
# =============================================================================
echo "[9/9] Deployment Summary"
echo "=========================================="
echo ""
echo "✓ encoderPro deployed successfully!"
echo ""
echo "Configuration:"
echo " - Container: encoderpro"
echo " - Image: ${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
echo " - CPU Workers: $MAX_WORKERS concurrent encodes"
echo " - CPU Utilization: Up to $CPU_LIMIT cores"
echo " - Memory Limit: $MEMORY_LIMIT"
echo ""
echo "Access Points:"
echo " - Dashboard: http://$(hostname -I | awk '{print $1}'):5000"
echo " - Logs: docker logs -f encoderpro"
echo " - Log File: $APP_DIR/logs/encoderpro.log"
echo ""
echo "Useful Commands:"
echo " - View stats: docker exec encoderpro python3 /app/reencode.py -c /config/config.yaml --stats"
echo " - Scan library: docker exec encoderpro python3 /app/reencode.py -c /config/config.yaml --scan-only"
echo " - Start encode: docker exec encoderpro python3 /app/reencode.py -c /config/config.yaml"
echo " - View logs: tail -f $APP_DIR/logs/encoderpro.log"
echo ""
echo "Container Status:"
docker ps -f name=encoderpro --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
echo ""
echo "=========================================="
echo "Deployment complete! 🚀"
echo "=========================================="