Spaces:
Sleeping
Sleeping
File size: 4,711 Bytes
7ffe51d |
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# Quick Deployment Script for Hugging Face Spaces (PowerShell)
# This script helps prepare your backend for deployment
Write-Host "🚀 TaskFlow Backend - Hugging Face Deployment Preparation" -ForegroundColor Cyan
Write-Host "==========================================================" -ForegroundColor Cyan
Write-Host ""
# Check if we're in the backend directory
if (-not (Test-Path "requirements.txt")) {
Write-Host "❌ Error: Please run this script from the backend directory" -ForegroundColor Red
exit 1
}
Write-Host "✅ Found backend directory" -ForegroundColor Green
Write-Host ""
# Check required files
Write-Host "📋 Checking required files..." -ForegroundColor Yellow
$files = @("Dockerfile", "requirements.txt", "alembic.ini", "src/main.py")
$missing_files = @()
foreach ($file in $files) {
if (Test-Path $file) {
Write-Host " ✅ $file" -ForegroundColor Green
} else {
Write-Host " ❌ $file (missing)" -ForegroundColor Red
$missing_files += $file
}
}
if ($missing_files.Count -gt 0) {
Write-Host ""
Write-Host "❌ Missing required files. Please ensure all files are present." -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "🔐 Generating secrets..." -ForegroundColor Yellow
# Generate BETTER_AUTH_SECRET (using .NET crypto)
$bytes = New-Object byte[] 32
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rng.GetBytes($bytes)
$SECRET = [System.BitConverter]::ToString($bytes).Replace("-", "").ToLower()
Write-Host ""
Write-Host "Your BETTER_AUTH_SECRET (save this!):" -ForegroundColor Cyan
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
Write-Host $SECRET -ForegroundColor Yellow
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Cyan
Write-Host ""
# Create deployment notes
$deploymentNotes = @"
TaskFlow Backend - Deployment Information
Generated: $(Get-Date)
BETTER_AUTH_SECRET: $SECRET
Required Environment Variables for Hugging Face:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. DATABASE_URL
Get from: Neon PostgreSQL Dashboard
Format: postgresql://user:password@host/database
2. BETTER_AUTH_SECRET
Value: $SECRET
3. CORS_ORIGINS
Initial: http://localhost:3000
After frontend deploy: https://your-app.vercel.app,https://your-app-*.vercel.app
4. DEBUG
Value: False
5. JWT_ALGORITHM (optional)
Value: HS256
6. JWT_EXPIRATION_DAYS (optional)
Value: 7
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Next Steps:
1. Create Hugging Face Space at https://huggingface.co/new-space
2. Choose Docker SDK
3. Clone the Space repository
4. Copy all backend files to the Space directory
5. Rename README_HF.md to README.md
6. Commit and push
7. Add environment variables in Space Settings
8. Wait for build to complete
"@
$deploymentNotes | Out-File -FilePath "DEPLOYMENT_NOTES.txt" -Encoding UTF8
Write-Host "📝 Deployment notes saved to: DEPLOYMENT_NOTES.txt" -ForegroundColor Green
Write-Host ""
# Check if Docker is available
$dockerInstalled = Get-Command docker -ErrorAction SilentlyContinue
if ($dockerInstalled) {
Write-Host "🐳 Docker is installed" -ForegroundColor Green
Write-Host ""
$response = Read-Host "Would you like to test the Docker build locally? (y/n)"
if ($response -eq "y" -or $response -eq "Y") {
Write-Host "Building Docker image..." -ForegroundColor Yellow
docker build -t taskflow-backend-test .
if ($LASTEXITCODE -eq 0) {
Write-Host "✅ Docker build successful!" -ForegroundColor Green
} else {
Write-Host "❌ Docker build failed. Please check the errors above." -ForegroundColor Red
}
}
} else {
Write-Host "ℹ️ Docker not found. Skipping local build test." -ForegroundColor Yellow
}
Write-Host ""
Write-Host "✅ Preparation complete!" -ForegroundColor Green
Write-Host ""
Write-Host "📚 Next steps:" -ForegroundColor Cyan
Write-Host " 1. Review DEPLOYMENT_NOTES.txt"
Write-Host " 2. Follow the deployment guide in ../DEPLOYMENT_GUIDE.md"
Write-Host " 3. Create your Hugging Face Space"
Write-Host " 4. Push your code"
Write-Host ""
|