#!/usr/bin/env pwsh # Trading Bot Docker Management Script param( [Parameter(Mandatory=$true)] [ValidateSet("start", "stop", "restart", "status", "logs", "reset", "admin", "monitoring", "help")] [string]$Action, [Parameter(Mandatory=$false)] [string]$Service = "", [Parameter(Mandatory=$false)] [switch]$Dev = $false ) $ComposeFiles = if ($Dev) { "-f docker-compose.yml -f docker-compose.dev.yml" } else { "-f docker-compose.yml" } switch ($Action) { "start" { Write-Host "🚀 Starting Trading Bot infrastructure..." -ForegroundColor Green if ($Service) { Invoke-Expression "docker-compose $ComposeFiles up -d $Service" } else { Invoke-Expression "docker-compose $ComposeFiles up -d dragonfly postgres questdb" } Write-Host "✅ Infrastructure started!" -ForegroundColor Green Write-Host "" Write-Host "🔗 Access Points:" -ForegroundColor Cyan Write-Host " Dragonfly: localhost:6379" Write-Host " PostgreSQL: localhost:5432" Write-Host " QuestDB Console: http://localhost:9000" Write-Host "" Write-Host "💡 Use './scripts/docker.ps1 admin' to start admin interfaces" } "stop" { Write-Host "🛑 Stopping Trading Bot infrastructure..." -ForegroundColor Yellow if ($Service) { Invoke-Expression "docker-compose $ComposeFiles stop $Service" } else { Invoke-Expression "docker-compose $ComposeFiles down" } Write-Host "✅ Infrastructure stopped!" -ForegroundColor Green } "restart" { Write-Host "🔄 Restarting Trading Bot infrastructure..." -ForegroundColor Yellow if ($Service) { Invoke-Expression "docker-compose $ComposeFiles restart $Service" } else { Invoke-Expression "docker-compose $ComposeFiles restart" } Write-Host "✅ Infrastructure restarted!" -ForegroundColor Green } "status" { Write-Host "📊 Trading Bot Infrastructure Status:" -ForegroundColor Cyan Invoke-Expression "docker-compose $ComposeFiles ps" Write-Host "" Write-Host "🔍 Health Checks:" -ForegroundColor Cyan docker ps --filter "name=trading-bot" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" } "logs" { if ($Service) { Write-Host "📋 Logs for ${Service}:" -ForegroundColor Cyan Invoke-Expression "docker-compose $ComposeFiles logs -f $Service" } else { Write-Host "📋 All service logs:" -ForegroundColor Cyan Invoke-Expression "docker-compose $ComposeFiles logs -f" } } "reset" { Write-Host "⚠️ Resetting Trading Bot infrastructure (will delete all data)..." -ForegroundColor Red $confirm = Read-Host "Are you sure? Type 'yes' to confirm" if ($confirm -eq "yes") { Invoke-Expression "docker-compose $ComposeFiles down -v" Write-Host "🗑️ Volumes removed" Invoke-Expression "docker-compose $ComposeFiles up -d dragonfly postgres questdb" Write-Host "✅ Infrastructure reset complete!" -ForegroundColor Green } else { Write-Host "❌ Reset cancelled" -ForegroundColor Yellow } } "admin" { Write-Host "🔧 Starting admin interfaces..." -ForegroundColor Green Invoke-Expression "docker-compose $ComposeFiles up -d redis-insight pgadmin" Write-Host "✅ Admin interfaces started!" -ForegroundColor Green Write-Host "" Write-Host "🔗 Admin Access:" -ForegroundColor Cyan Write-Host " Redis Insight: http://localhost:8001" Write-Host " PgAdmin: http://localhost:8080" Write-Host " Email: admin@tradingbot.local" Write-Host " Password: admin123" } "monitoring" { Write-Host "📊 Starting monitoring stack..." -ForegroundColor Green Invoke-Expression "docker-compose $ComposeFiles up -d prometheus grafana loki" Write-Host "✅ Monitoring started!" -ForegroundColor Green Write-Host "" Write-Host "🔗 Monitoring Access:" -ForegroundColor Cyan Write-Host " Prometheus: http://localhost:9090" Write-Host " Grafana: http://localhost:3000" Write-Host " Username: admin" Write-Host " Password: admin" Write-Host " Loki: http://localhost:3100" } "help" { Write-Host "" Write-Host "🤖 Trading Bot Docker Management" -ForegroundColor Green Write-Host "" Write-Host "Usage: ./scripts/docker.ps1 [options]" -ForegroundColor Cyan Write-Host "" Write-Host "Actions:" -ForegroundColor Yellow Write-Host " start Start infrastructure services" Write-Host " stop Stop infrastructure services" Write-Host " restart Restart infrastructure services" Write-Host " status Show service status" Write-Host " logs Show service logs" Write-Host " reset Reset all data (destructive)" Write-Host " admin Start admin interfaces" Write-Host " monitoring Start monitoring stack" Write-Host " help Show this help" Write-Host "" Write-Host "Options:" -ForegroundColor Yellow Write-Host " -Service Specify a specific service" Write-Host " -Dev Use development configuration" Write-Host "" Write-Host "Examples:" -ForegroundColor Cyan Write-Host " ./scripts/docker.ps1 start" Write-Host " ./scripts/docker.ps1 start -Dev" Write-Host " ./scripts/docker.ps1 logs -Service dragonfly" Write-Host " ./scripts/docker.ps1 admin" } }