|
| 1 | +param( |
| 2 | + $XM1 |
| 3 | +) |
| 4 | + |
| 5 | + |
| 6 | +Write-Host "The purpose of this script to start setup from scratch`n" -ForegroundColor Magenta |
| 7 | +Write-Host " 1. Stop all containers`n" -ForegroundColor DarkCyan |
| 8 | +Write-Host " 2. Docker Prune -Remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes`n" -ForegroundColor DarkCyan |
| 9 | +Write-Host " 3. Stop IIS, Stop/Start Host Network Service (HNS)`n" -ForegroundColor DarkCyan |
| 10 | +Write-Host " 4. Run .\clean.ps1 from Sitecore > Docker`n" -ForegroundColor DarkCyan |
| 11 | +Write-Host " 5. Restore Sitecore CLI Tool`n" -ForegroundColor DarkCyan |
| 12 | +Write-Host " 6. Run docker compose up command`n" -ForegroundColor DarkCyan |
| 13 | + |
| 14 | +Write-Host "`n`n1. Stop all containers..." -ForegroundColor Cyan |
| 15 | +docker container stop $(docker container ls -q --filter name=docker-examples*); |
| 16 | +docker-compose stop; docker-compose down |
| 17 | + |
| 18 | +Write-Host "`n`n2. Docker Prune" -ForegroundColor Cyan |
| 19 | +docker system prune |
| 20 | +docker rmi $(docker images --format "{{.Repository}}:{{.Tag}}" | findstr "docker-examples") |
| 21 | + |
| 22 | + |
| 23 | +if ($XM1 -ieq 'XM1') { |
| 24 | + docker rmi $(docker images --format "{{.Repository}}:{{.Tag}}" | findstr "docker-examples-xm1") |
| 25 | +} |
| 26 | +elseif ($XM1 -ieq 'XP1') { |
| 27 | + docker rmi $(docker images --format "{{.Repository}}:{{.Tag}}" | findstr "docker-examples-xp1") |
| 28 | +} |
| 29 | +else { |
| 30 | + docker rmi $(docker images --format "{{.Repository}}:{{.Tag}}" | findstr "docker-examples-xp0") |
| 31 | +} |
| 32 | + |
| 33 | +Write-Host "`n`n3. Stop IIS, Stop/Start Host Network Service (HNS)" -ForegroundColor Cyan |
| 34 | +iisreset /stop; net stop hns; net start hns |
| 35 | + |
| 36 | +Write-Host "`n`n4. Clean all previous build artifacts" -ForegroundColor Cyan |
| 37 | +Push-Location docker |
| 38 | +.\clean.ps1 |
| 39 | + |
| 40 | +Write-Host "`n`n5. Restore Sitecore CLI tool" -ForegroundColor Cyan |
| 41 | +Pop-Location |
| 42 | +dotnet tool restore |
| 43 | + |
| 44 | +Write-Host "`n`n6. Build/Compose Docker" -ForegroundColor Cyan |
| 45 | +Pop-Location |
| 46 | + |
| 47 | + |
| 48 | +if ($XM1 -ieq 'XM1') { |
| 49 | + Write-Host "Start Up script for XM1......" -ForegroundColor Cyan |
| 50 | + docker-compose -f docker-compose.xm1.yml -f docker-compose.xm1.override.yml up -d |
| 51 | +} |
| 52 | +elseif ($XM1 -ieq 'XP1') { |
| 53 | + Write-Host "Start Up script for XP1......" -ForegroundColor Cyan |
| 54 | + docker-compose -f docker-compose.xp1.yml -f docker-compose.xp1.override.yml up -d |
| 55 | +} |
| 56 | +else { |
| 57 | + Write-Host "Start Up script for XP0......" -ForegroundColor Cyan |
| 58 | + docker-compose up -d |
| 59 | +} |
| 60 | + |
| 61 | +Write-Host "***Setup completed successfully***" -ForegroundColor Green |
0 commit comments