152 lines
4.4 KiB
Bash
152 lines
4.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Discord Voice Translator V2 - Deployment Script
|
|
# Run this script to deploy the complete system on your Unraid server
|
|
|
|
set -e
|
|
|
|
echo "🎤 Discord Voice Translator V2 - Deployment Script"
|
|
echo "=================================================="
|
|
|
|
# Check if Docker and Docker Compose are available
|
|
if ! command -v docker &> /dev/null; then
|
|
echo "❌ Docker is not installed or not in PATH"
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v docker-compose &> /dev/null; then
|
|
echo "❌ Docker Compose is not installed or not in PATH"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if NVIDIA runtime is available (for GPU support)
|
|
if docker info | grep -q nvidia; then
|
|
echo "✅ NVIDIA Docker runtime detected"
|
|
else
|
|
echo "⚠️ NVIDIA Docker runtime not detected - GPU acceleration will not work"
|
|
echo " Please install nvidia-docker2 and restart Docker daemon"
|
|
fi
|
|
|
|
# Check if .env file exists
|
|
if [ ! -f .env ]; then
|
|
echo "📝 Creating .env file from template..."
|
|
cp .env.example .env
|
|
echo "⚠️ Please edit .env file with your configuration before continuing!"
|
|
echo " Required: DISCORD_TOKEN, CLIENT_ID, GUILD_ID, POSTGRES_PASSWORD"
|
|
echo " Optional: GOOGLE_TRANSLATE_API_KEY for premium translations"
|
|
read -p "Press Enter after you've configured .env file..."
|
|
fi
|
|
|
|
# Create necessary directories
|
|
echo "📁 Creating data directories..."
|
|
mkdir -p data/audio/raw
|
|
mkdir -p data/audio/processed
|
|
mkdir -p data/database
|
|
mkdir -p data/redis
|
|
mkdir -p data/logs
|
|
mkdir -p data/models
|
|
|
|
# Set permissions
|
|
echo "🔐 Setting directory permissions..."
|
|
chmod 755 data/
|
|
chmod 755 data/audio/
|
|
chmod 755 data/audio/raw/
|
|
chmod 755 data/audio/processed/
|
|
chmod 755 data/database/
|
|
chmod 755 data/redis/
|
|
chmod 755 data/logs/
|
|
chmod 755 data/models/
|
|
|
|
# Pull required base images
|
|
echo "📦 Pulling required Docker images..."
|
|
docker pull postgres:15-alpine
|
|
docker pull redis:7-alpine
|
|
docker pull nginx:alpine
|
|
docker pull nvidia/cuda:11.8-runtime-ubuntu22.04
|
|
docker pull python:3.11-slim
|
|
docker pull node:18-alpine
|
|
|
|
# Build all services
|
|
echo "🔨 Building all services..."
|
|
docker-compose build --parallel
|
|
|
|
# Start infrastructure services first
|
|
echo "🚀 Starting infrastructure services..."
|
|
docker-compose up -d postgres redis
|
|
|
|
# Wait for database to be ready
|
|
echo "⏳ Waiting for database to be ready..."
|
|
sleep 10
|
|
|
|
# Check database connection
|
|
docker-compose exec postgres pg_isready -U postgres
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ Database is ready"
|
|
else
|
|
echo "❌ Database failed to start"
|
|
exit 1
|
|
fi
|
|
|
|
# Start all services
|
|
echo "🚀 Starting all services..."
|
|
docker-compose up -d
|
|
|
|
# Wait for services to start
|
|
echo "⏳ Waiting for services to start..."
|
|
sleep 15
|
|
|
|
# Check service health
|
|
echo "🔍 Checking service health..."
|
|
|
|
services=("recorder" "audio-processor" "whisper-service" "translator" "transcriber" "dashboard")
|
|
healthy=0
|
|
|
|
for service in "${services[@]}"; do
|
|
if docker-compose ps $service | grep -q "Up"; then
|
|
echo "✅ $service is running"
|
|
((healthy++))
|
|
else
|
|
echo "❌ $service failed to start"
|
|
docker-compose logs $service
|
|
fi
|
|
done
|
|
|
|
# Show status
|
|
echo ""
|
|
echo "📊 Deployment Status:"
|
|
echo "===================="
|
|
echo "Services running: $healthy/${#services[@]}"
|
|
|
|
if [ $healthy -eq ${#services[@]} ]; then
|
|
echo "🎉 All services are running successfully!"
|
|
echo ""
|
|
echo "🌐 Dashboard URL: http://localhost:3000"
|
|
echo "🎤 Whisper API: http://localhost:8001"
|
|
echo "🌍 Translation API: http://localhost:8002"
|
|
echo ""
|
|
echo "📋 Next Steps:"
|
|
echo "1. Open the dashboard: http://localhost:3000"
|
|
echo "2. Invite your Discord bot to a server"
|
|
echo "3. Join a voice channel and use /join command"
|
|
echo "4. Start speaking and watch real-time translations!"
|
|
echo ""
|
|
echo "🔧 Admin Interfaces (optional):"
|
|
echo " PostgreSQL: http://localhost:8080 (pgAdmin)"
|
|
echo " Redis: http://localhost:8081 (Redis Commander)"
|
|
echo " Start with: docker-compose --profile admin up -d"
|
|
echo ""
|
|
echo "📖 Documentation: Check README.md for detailed usage"
|
|
echo "🐛 Troubleshooting: docker-compose logs <service-name>"
|
|
else
|
|
echo "❌ Some services failed to start"
|
|
echo "📋 Troubleshooting steps:"
|
|
echo "1. Check logs: docker-compose logs"
|
|
echo "2. Verify .env configuration"
|
|
echo "3. Ensure NVIDIA runtime is installed for GPU support"
|
|
echo "4. Check port conflicts: netstat -tulpn | grep -E ':(3000|5432|6379|8001|8002)'"
|
|
fi
|
|
|
|
echo ""
|
|
echo "📊 Current Status:"
|
|
docker-compose ps
|