#!/bin/bash # Update Textilindo AI Assistant on Hugging Face Spaces # This script will update your existing HF Space with the Docker fixes set -e SPACE_DIR="Textilindo" REPO_URL="https://huggingface.co/spaces/harismlnaslm/Textilindo" echo "🚀 Updating Textilindo AI Assistant on Hugging Face Spaces" echo "Repository: $REPO_URL" echo "" # Check if the space directory already exists if [ -d "$SPACE_DIR" ]; then echo "📁 Using existing repository: $SPACE_DIR" cd "$SPACE_DIR" # Pull latest changes echo "📥 Pulling latest changes..." git pull origin main else echo "📥 Cloning space repository..." echo "⚠️ You'll need to use your Hugging Face access token as password" echo " Get your token from: https://huggingface.co/settings/tokens" echo "" git clone "$REPO_URL" cd "$SPACE_DIR" fi echo "📋 Copying updated files to space repository..." # Copy the fixed files echo "✅ Copying app_gradio.py (with Docker fixes)..." cp ../app_gradio.py . echo "✅ Copying updated Dockerfile (points to app_gradio.py)..." cp ../Dockerfile . echo "✅ Copying requirements.txt..." cp ../requirements.txt . echo "✅ Copying README.md..." cp ../README.md . # Copy templates directory if [ -d "../templates" ]; then cp -r ../templates . echo "✅ Templates copied" fi # Copy configs directory if [ -d "../configs" ]; then cp -r ../configs . echo "✅ Configs copied" fi # Copy data directory (if exists) if [ -d "../data" ]; then cp -r ../data . echo "✅ Data copied" fi # Copy the deployment guide if [ -f "../HF_SPACES_DEPLOYMENT.md" ]; then cp ../HF_SPACES_DEPLOYMENT.md . echo "✅ Deployment guide copied" fi echo "" echo "📝 Files ready for deployment:" ls -la echo "" echo "🔧 Key fixes included:" echo "✅ Dockerfile now points to app_gradio.py" echo "✅ app_gradio.py has enhanced error handling" echo "✅ Process keep-alive mechanism added" echo "✅ Fallback interface for error recovery" echo "" echo "🚀 Ready to deploy! Run these commands:" echo "" echo "git add ." echo "git commit -m 'Fix: Docker container stopping issue - Enhanced Gradio interface'" echo "git push" echo "" echo "🌐 Your updated app will be available at: $REPO_URL" echo "" echo "📊 Monitor the deployment:" echo "1. Go to: https://huggingface.co/spaces/harismlnaslm/Textilindo" echo "2. Check the 'Logs' tab to see the build progress" echo "3. Wait for the build to complete (usually 2-5 minutes)" echo "" echo "✅ The container should now stay alive and serve your app properly!"