Spaces:
Paused
Paused
File size: 2,472 Bytes
8822914 566c982 8822914 154ed69 2a87088 154ed69 2a87088 8822914 2a87088 8822914 2a87088 8822914 566c982 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
#!/bin/bash
set -e # Exit the script if any statement returns a non-true return value
echo "=== Starting AI Toolkit ==="
echo "Working directory: $(pwd)"
echo "User: $(whoami)"
# Create base directory
mkdir -p /data/ai-toolkit
# Sync all files including frontend but important: we MUST preserve data folders
# (I had a situation where I lost precious data because I didn't had those excludes before...)
echo "Syncing codebase..."
rsync -a --exclude='config' --exclude='output' --exclude='aitk_db.db' --exclude='datasets' \
/app/ /data/ai-toolkit/
echo "✓ Codebase synced"
# Ensure persistent directories exist
echo "Creating persistent directories..."
mkdir -p /data/ai-toolkit/database
echo "✓ Database directory ready"
# Set database URL to use organized persistent directory
export DATABASE_URL="file:/data/ai-toolkit/database/aitk_db.db"
echo "Database URL set to: $DATABASE_URL"
# Set HuggingFace cache directories to writable location
export HF_HOME="/data/huggingface"
export HUGGINGFACE_HUB_CACHE="/data/huggingface/hub"
export TRANSFORMERS_CACHE="/data/huggingface/transformers"
export DIFFUSERS_CACHE="/data/huggingface/diffusers"
echo "HuggingFace cache set to: $HF_HOME"
# Create HuggingFace cache directories
mkdir -p "$HF_HOME"
mkdir -p "$HUGGINGFACE_HUB_CACHE"
mkdir -p "$TRANSFORMERS_CACHE"
mkdir -p "$DIFFUSERS_CACHE"
# Change to the writable UI directory
echo "Changing to writable UI directory..."
cd /data/ai-toolkit/ui
echo "Current directory: $(pwd)"
# Run database migrations/setup if needed
echo "=== Updating dependencies ==="
npm install
echo "✓ Dependencies updated"
# Run database migrations/setup if needed
echo "=== Setting up database ==="
# Generate Prisma client (now with full write access)
echo "Generating Prisma client..."
npx prisma generate --schema prisma/schema.prisma
echo "✓ Prisma client generated"
# Push schema to create database tables
echo "Creating database tables..."
npx prisma db push --schema prisma/schema.prisma --skip-generate
echo "✓ Database tables created"
# Build the app
echo "=== Building app ==="
npm run build
echo "✓ App built"
# Start the application with HuggingFace cache environment variables
echo ""
echo "=== Starting application ==="
echo "Environment variables for HuggingFace:"
echo " HF_HOME=$HF_HOME"
echo " HUGGINGFACE_HUB_CACHE=$HUGGINGFACE_HUB_CACHE"
echo " TRANSFORMERS_CACHE=$TRANSFORMERS_CACHE"
echo " DIFFUSERS_CACHE=$DIFFUSERS_CACHE"
npm run start |