|
| 1 | +Param([string] $rootPath) |
| 2 | +$scriptPath = Split-Path $script:MyInvocation.MyCommand.Path |
| 3 | + |
| 4 | +Write-Host "Current script directory is $scriptPath" -ForegroundColor Yellow |
| 5 | + |
| 6 | +if ([string]::IsNullOrEmpty($rootPath)) { |
| 7 | + $rootPath = "$scriptPath\..\.." |
| 8 | +} |
| 9 | +Write-Host "Root path used is $rootPath" -ForegroundColor Yellow |
| 10 | + |
| 11 | + |
| 12 | +$projectPaths = |
| 13 | + @{Path="$rootPath\src\Web\WebMVC";Prj="WebMVC.csproj"}, |
| 14 | + @{Path="$rootPath\src\Web\WebSPA";Prj="WebSPA.csproj"}, |
| 15 | + @{Path="$rootPath\src\Services\Identity\Identity.API";Prj="Identity.API.csproj"}, |
| 16 | + @{Path="$rootPath\src\Services\Catalog\Catalog.API";Prj="Catalog.API.csproj"}, |
| 17 | + @{Path="$rootPath\src\Services\Ordering\Ordering.API";Prj="Ordering.API.csproj"}, |
| 18 | + @{Path="$rootPath\src\Services\Basket\Basket.API";Prj="Basket.API.csproj"}, |
| 19 | + @{Path="$rootPath\src\Services\Location\Locations.API";Prj="Locations.API.csproj"}, |
| 20 | + @{Path="$rootPath\src\Services\Marketing\Marketing.API";Prj="Marketing.API.csproj"}, |
| 21 | + @{Path="$rootPath\src\Services\Payment\Payment.API";Prj="Payment.API.csproj"}, |
| 22 | + @{Path="$rootPath\src\Web\WebStatus";Prj="WebStatus.csproj"} |
| 23 | + |
| 24 | +$projectPaths | foreach { |
| 25 | + $projectPath = $_.Path |
| 26 | + $projectFile = $_.Prj |
| 27 | + $outPath = $_.Path + "\obj\Docker\publish" |
| 28 | + $projectPathAndFile = "$projectPath\$projectFile" |
| 29 | + Write-Host "Deleting old publish files in $outPath" -ForegroundColor Yellow |
| 30 | + remove-item -path $outPath -Force -Recurse -ErrorAction SilentlyContinue |
| 31 | + Write-Host "Publishing $projectPathAndFile to $outPath" -ForegroundColor Yellow |
| 32 | + dotnet restore $projectPathAndFile |
| 33 | + dotnet build $projectPathAndFile |
| 34 | + dotnet publish $projectPathAndFile -o $outPath |
| 35 | + } |
| 36 | + |
| 37 | +######################################################################################## |
| 38 | +# Delete old eShop Docker images |
| 39 | +######################################################################################## |
| 40 | + |
| 41 | +$imagesToDelete = docker images --filter=reference="eshop/*" -q |
| 42 | + |
| 43 | +If (-Not $imagesToDelete) {Write-Host "Not deleting eShop images as there are no eShop images in the current local Docker repo."} |
| 44 | +Else |
| 45 | +{ |
| 46 | + # Delete all containers |
| 47 | + Write-Host "Deleting all containers in local Docker Host" |
| 48 | + docker rm $(docker ps -a -q) -f |
| 49 | + |
| 50 | + # Delete all eshop images |
| 51 | + Write-Host "Deleting eShop images in local Docker repo" |
| 52 | + Write-Host $imagesToDelete |
| 53 | + docker rmi $(docker images --filter=reference="eshop/*" -q) -f |
| 54 | +} |
| 55 | + |
| 56 | +# WE DON'T NEED DOCKER BUILD AS WE CAN RUN "DOCKER-COMPOSE BUILD" OR "DOCKER-COMPOSE UP" AND IT WILL BUILD ALL THE IMAGES IN THE .YML FOR US |
0 commit comments