#!/bin/bash # Drakkenheim RAG Application Deployment Script # This script helps you deploy the RAG application using Docker Compose set -e echo "🚀 Drakkenheim RAG Application Deployment" echo "========================================" # Check if Docker is installed if ! command -v docker &> /dev/null; then echo "❌ Docker is not installed. Please install Docker first." exit 1 fi # Check if Docker Compose is available if ! docker compose version &> /dev/null; then echo "❌ Docker Compose is not available. Please ensure Docker is up to date." exit 1 fi # Check if .env file exists if [ ! -f .env ]; then echo "📝 Creating .env file from template..." cp env.example .env echo "" echo "🔐 Setting up authentication..." echo "Generating secure password hash..." python3 generate_password.py echo "" echo "⚠️ Please edit .env file and add your OpenAI API key:" echo " nano .env" echo "" read -p "Press Enter after you've added your API key..." fi # Check if OPENAI_API_KEY is set if ! grep -q "OPENAI_API_KEY=sk-" .env; then echo "❌ OPENAI_API_KEY not found in .env file." echo "Please edit .env file and add your OpenAI API key:" echo " OPENAI_API_KEY=sk-your-key-here" exit 1 fi # Check if authentication is configured if ! grep -q "APP_PASSWORD_HASH=" .env || grep -q "APP_PASSWORD_HASH=your_hashed_password_here" .env; then echo "⚠️ Authentication not configured. Generating secure password..." python3 generate_password.py echo "" echo "Please copy the generated values to your .env file and restart deployment." exit 1 fi echo "✅ Environment configuration looks good!" # Build the Docker image echo "🔨 Building Docker image..." docker compose build # Start the application echo "🚀 Starting RAG application..." docker compose up -d # Wait for the application to start echo "⏳ Waiting for application to start..." sleep 10 # Check if the application is running if docker compose ps | grep -q "Up"; then echo "✅ Application is running!" echo "" echo "🌐 Access your RAG application at:" echo " http://localhost:8501" echo "" echo "📊 To view logs:" echo " make docker-logs" echo "" echo "🛑 To stop the application:" echo " make docker-down" echo "" echo "📋 To backup your data:" echo " make docker-backup" else echo "❌ Application failed to start. Check logs with:" echo " make docker-logs" exit 1 fi