Spaces:
Running
Running
# Madverse Music Deployment Script for Windows | |
# Run with: .\deploy.ps1 | |
Write-Host "π΅ Deploying Madverse Music API..." -ForegroundColor Cyan | |
# Check if Docker is installed | |
try { | |
docker --version | Out-Null | |
Write-Host "β Docker found" -ForegroundColor Green | |
} catch { | |
Write-Host "β Docker is not installed. Please install Docker Desktop first." -ForegroundColor Red | |
exit 1 | |
} | |
# Check if docker-compose is installed | |
try { | |
docker-compose --version | Out-Null | |
Write-Host "β Docker Compose found" -ForegroundColor Green | |
} catch { | |
Write-Host "β Docker Compose is not installed. Please install Docker Desktop with Compose." -ForegroundColor Red | |
exit 1 | |
} | |
# Set environment variables | |
if (-not $env:MADVERSE_API_KEY) { | |
$env:MADVERSE_API_KEY = "madverse-music-api-key-2024" | |
} | |
Write-Host "π§ Building Docker image..." -ForegroundColor Yellow | |
docker-compose build | |
if ($LASTEXITCODE -ne 0) { | |
Write-Host "β Failed to build Docker image" -ForegroundColor Red | |
exit 1 | |
} | |
Write-Host "π Starting services..." -ForegroundColor Yellow | |
docker-compose up -d | |
if ($LASTEXITCODE -ne 0) { | |
Write-Host "β Failed to start services" -ForegroundColor Red | |
exit 1 | |
} | |
Write-Host "β³ Waiting for services to be healthy..." -ForegroundColor Yellow | |
Start-Sleep -Seconds 30 | |
# Test the API | |
Write-Host "π§ͺ Testing API health..." -ForegroundColor Yellow | |
try { | |
$response = Invoke-WebRequest -Uri "http://localhost:8000/health" -Method GET -TimeoutSec 10 | |
if ($response.StatusCode -eq 200) { | |
Write-Host "β API is healthy and running!" -ForegroundColor Green | |
Write-Host "π API URL: http://localhost:8000" -ForegroundColor Cyan | |
Write-Host "π API Docs: http://localhost:8000/" -ForegroundColor Cyan | |
Write-Host "π API Key: $env:MADVERSE_API_KEY" -ForegroundColor Cyan | |
} else { | |
throw "Health check failed" | |
} | |
} catch { | |
Write-Host "β API health check failed. Check logs:" -ForegroundColor Red | |
docker-compose logs madverse-api | |
exit 1 | |
} | |
Write-Host "" | |
Write-Host "π― Quick Test Command:" -ForegroundColor Yellow | |
Write-Host "Invoke-RestMethod -Uri 'http://localhost:8000/analyze' -Method POST -Headers @{'X-API-Key'='$env:MADVERSE_API_KEY'; 'Content-Type'='application/json'} -Body '{`"urls`": [`"https://example.com/song.mp3`"]}'" -ForegroundColor Gray |