60 lines
2.4 KiB
PowerShell
60 lines
2.4 KiB
PowerShell
# Docker Build Script for China Users (PowerShell)
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Docker Build Script for China Users" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# Set environment variables for China
|
|
$env:DOCKER_BUILDKIT = 1
|
|
$env:COMPOSE_DOCKER_CLI_BUILD = 1
|
|
$env:BUILDKIT_PROGRESS = "plain"
|
|
|
|
Write-Host "Step 1: Cleaning up old builds..." -ForegroundColor Yellow
|
|
docker system prune -f
|
|
docker builder prune -f
|
|
Write-Host ""
|
|
|
|
Write-Host "Step 2: Building backend service (this may take a while)..." -ForegroundColor Yellow
|
|
$backendStart = Get-Date
|
|
docker-compose build --no-cache backend
|
|
$backendExitCode = $LASTEXITCODE
|
|
$backendEnd = Get-Date
|
|
$backendDuration = ($backendEnd - $backendStart).TotalMinutes
|
|
Write-Host "Backend build took: $backendDuration minutes" -ForegroundColor Gray
|
|
|
|
if ($backendExitCode -ne 0) {
|
|
Write-Host "Backend build failed!" -ForegroundColor Red
|
|
Write-Host "Trying again with verbose output..." -ForegroundColor Yellow
|
|
docker build --no-cache -t sillytavern-repalice-backend -f docker/backend.Dockerfile .
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Backend build failed again. Please check the error messages above." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
Write-Host ""
|
|
|
|
Write-Host "Step 3: Building frontend service (this may take a while)..." -ForegroundColor Yellow
|
|
$frontendStart = Get-Date
|
|
docker-compose build --no-cache frontend
|
|
$frontendExitCode = $LASTEXITCODE
|
|
$frontendEnd = Get-Date
|
|
$frontendDuration = ($frontendEnd - $frontendStart).TotalMinutes
|
|
Write-Host "Frontend build took: $frontendDuration minutes" -ForegroundColor Gray
|
|
|
|
if ($frontendExitCode -ne 0) {
|
|
Write-Host "Frontend build failed!" -ForegroundColor Red
|
|
Write-Host "Trying again with verbose output..." -ForegroundColor Yellow
|
|
docker build --no-cache -t sillytavern-repalice-frontend -f docker/frontend.Dockerfile .
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Frontend build failed again. Please check the error messages above." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
Write-Host ""
|
|
|
|
Write-Host "========================================" -ForegroundColor Green
|
|
Write-Host "Build completed successfully!" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "You can now run: docker-compose up -d" -ForegroundColor White
|