schon/scripts/Windows/install.ps1
Egor fureunoir Gorbunov 1e8d053ab6 Features: 1) OS-specific scripts for deployments.
2) Healthcheck improvements.
Fixes: merge_recently_viewed for UserViewSet
2025-06-11 02:54:46 +03:00

45 lines
1.2 KiB
PowerShell

#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
if (-not (Test-Path '.env'))
{
Write-Warning ".env file not found. Exiting without running Docker steps."
exit 0
}
$cpuCount = [Environment]::ProcessorCount
if ($cpuCount -lt 4)
{
Write-Error "Insufficient CPU cores: $cpuCount detected. Minimum 4 required."
exit 1
}
$totalMemBytes = (Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory
$totalMemGB = [Math]::Round($totalMemBytes / 1GB, 2)
if ($totalMemGB -lt 6)
{
Write-Error "Insufficient RAM: $totalMemGB GB detected. Minimum 6 GB required."
exit 1
}
$currentDrive = Split-Path -Qualifier $PWD
$driveLetter = $currentDrive.Substring(0, 1)
$driveInfo = Get-PSDrive -Name $driveLetter
$freeGB = [Math]::Round($driveInfo.Free / 1GB, 2)
if ($freeGB -lt 20)
{
Write-Error "Insufficient free disk space on drive $driveLetter`: $freeGB GB available. Minimum 20 GB required."
exit 1
}
Write-Host "System requirements met:" `
"CPU cores=$cpuCount," `
"RAM=${totalMemGB}GB," `
"FreeDisk=${freeGB}GB" -ForegroundColor Green
Write-Host "Pulling related images..." -ForegroundColor Green
docker compose pull
Write-Host "Building the project's images..." -ForegroundColor Green
docker compose build