48 lines
1.6 KiB
PowerShell
48 lines
1.6 KiB
PowerShell
# Rebuild and restart containers with latest code
|
|
param(
|
|
[string]$Server = "45.249.208.118",
|
|
[string]$User = "root",
|
|
[string]$Password = "lxvhNYFZ4160",
|
|
[string]$ProjectPath = "/root/youyidian-3d"
|
|
)
|
|
|
|
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
|
|
|
|
Write-Host "Rebuilding and restarting containers..." -ForegroundColor Yellow
|
|
Write-Host "This may take several minutes..." -ForegroundColor Gray
|
|
Write-Host ""
|
|
|
|
# Stop and remove containers
|
|
Write-Host "1. Stopping containers..." -ForegroundColor Cyan
|
|
$cmd = "cd $ProjectPath; docker compose down"
|
|
& $plinkPath -ssh -pw $Password -batch "${User}@${Server}" $cmd
|
|
Write-Host ""
|
|
|
|
# Rebuild and start
|
|
Write-Host "2. Rebuilding and starting containers..." -ForegroundColor Cyan
|
|
$cmd = "cd $ProjectPath; docker compose up -d --build --force-recreate 2>&1"
|
|
& $plinkPath -ssh -pw $Password -batch "${User}@${Server}" $cmd
|
|
Write-Host ""
|
|
|
|
# Wait for startup
|
|
Write-Host "3. Waiting for containers to start..." -ForegroundColor Cyan
|
|
Start-Sleep -Seconds 10
|
|
|
|
# Check status
|
|
Write-Host "4. Checking container status..." -ForegroundColor Cyan
|
|
$cmd = "cd $ProjectPath; docker compose ps"
|
|
& $plinkPath -ssh -pw $Password -batch "${User}@${Server}" $cmd
|
|
Write-Host ""
|
|
|
|
# Check logs
|
|
Write-Host "5. Application logs (last 30 lines):" -ForegroundColor Cyan
|
|
$cmd = "cd $ProjectPath; docker compose logs app --tail=30 2>&1"
|
|
& $plinkPath -ssh -pw $Password -batch "${User}@${Server}" $cmd
|
|
Write-Host ""
|
|
|
|
Write-Host "Rebuild complete!" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Application should be running at:" -ForegroundColor Yellow
|
|
Write-Host " http://45.249.208.118:4320" -ForegroundColor White
|
|
Write-Host ""
|