intent-classification / docker-deploy.ps1
khanarham's picture
Upload folder using huggingface_hub
9207866 verified
Raw History Blame Contribute Delete
2.84 kB
# Docker Build and Run Script
# Builds the Docker image and runs the container
Write-Host "Intent Classification API - Docker Deployment" -ForegroundColor Cyan
Write-Host "==============================================" -ForegroundColor Cyan
Write-Host ""
# Check if model exists
if (-not (Test-Path "finetuned_intent_falconsai")) {
Write-Host "ERROR: Model directory 'finetuned_intent_falconsai' not found!" -ForegroundColor Red
Write-Host "Please run the training script first:" -ForegroundColor Yellow
Write-Host " python fine-tuning-falcon-ai.py" -ForegroundColor Yellow
exit 1
}
Write-Host "✓ Model directory found" -ForegroundColor Green
Write-Host ""
# Build Docker image
Write-Host "Building Docker image..." -ForegroundColor Cyan
docker build -t intent-classifier:latest .
if ($LASTEXITCODE -ne 0) {
Write-Host "✗ Docker build failed" -ForegroundColor Red
exit 1
}
Write-Host "✓ Docker image built successfully" -ForegroundColor Green
Write-Host ""
# Stop and remove existing container if running
Write-Host "Checking for existing container..." -ForegroundColor Cyan
$existingContainer = docker ps -a -q -f name=intent-api
if ($existingContainer) {
Write-Host "Stopping and removing existing container..." -ForegroundColor Yellow
docker stop intent-api
docker rm intent-api
}
# Run the container
Write-Host "Starting container..." -ForegroundColor Cyan
docker run -d -p 8000:8000 --name intent-api intent-classifier:latest
if ($LASTEXITCODE -eq 0) {
Write-Host "✓ Container started successfully" -ForegroundColor Green
Write-Host ""
Write-Host "API is running at: http://localhost:8000" -ForegroundColor Yellow
Write-Host "Interactive docs: http://localhost:8000/docs" -ForegroundColor Yellow
Write-Host ""
Write-Host "Useful commands:" -ForegroundColor Cyan
Write-Host " View logs: docker logs -f intent-api" -ForegroundColor Gray
Write-Host " Stop: docker stop intent-api" -ForegroundColor Gray
Write-Host " Restart: docker restart intent-api" -ForegroundColor Gray
Write-Host " Remove: docker rm -f intent-api" -ForegroundColor Gray
Write-Host ""
Write-Host "Waiting for API to be ready..." -ForegroundColor Cyan
Start-Sleep -Seconds 5
# Test health endpoint
try {
$response = Invoke-RestMethod -Uri "http://localhost:8000/health" -Method Get -TimeoutSec 10
Write-Host "✓ API is healthy and ready!" -ForegroundColor Green
Write-Host ($response | ConvertTo-Json)
} catch {
Write-Host "⚠ API is starting... Check logs with: docker logs -f intent-api" -ForegroundColor Yellow
}
} else {
Write-Host "✗ Failed to start container" -ForegroundColor Red
exit 1
}