You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
4.5 KiB

  1. $scriptPath = Split-Path $script:MyInvocation.MyCommand.Path
  2. Write-Host "Current script directory is $scriptPath" -ForegroundColor Yellow
  3. $pubFolderToDelete = $scriptPath + "\pub"
  4. remove-item -path $pubFolderToDelete -Force -Recurse -ErrorAction SilentlyContinue
  5. # *** WebMVC image ***
  6. $webPathToJson = $scriptPath + "\src\Web\WebMVC\project.json"
  7. Write-Host "webPathToJson is $webPathToJson" -ForegroundColor Yellow
  8. $webPathToPub = $scriptPath + "\pub\webMVC"
  9. Write-Host "webPathToPub is $webPathToPub" -ForegroundColor Yellow
  10. Write-Host "Restore Dependencies just in case as it is needed to run dotnet publish" -ForegroundColor Blue
  11. dotnet restore $webPathToJson
  12. dotnet build $webPathToJson
  13. dotnet publish $webPathToJson -o $webPathToPub
  14. # *** WebSPA image ***
  15. $webSPAPath = $scriptPath + "\src\Web\WebSPA\eShopOnContainers.WebSPA"
  16. $webSPAPathToJson = $webSPAPath + "\project.json"
  17. Write-Host "webSPAPathToJson is $webSPAPathToJson" -ForegroundColor Yellow
  18. $webSPAPathToPub = $scriptPath + "\pub\webSPA"
  19. Write-Host "webSPAPathToPub is $webSPAPathToPub" -ForegroundColor Yellow
  20. Write-Host "Installing npm dependencies"
  21. Start-Process -WorkingDirectory $webSPAPath -NoNewWindow -Wait npm i
  22. Write-Host "Restore Dependencies just in case as it is needed to run dotnet publish" -ForegroundColor Blue
  23. dotnet restore $webSPAPathToJson
  24. dotnet build $webSPAPathToJson
  25. dotnet publish $webSPAPathToJson -o $webSPAPathToPub
  26. # *** identitySvc image ***
  27. $identitySvcPathToJson = $scriptPath + "\src\Services\Identity\Identity.API\project.json"
  28. Write-Host "identitySvcPathToJson is $identitySvcPathToJson" -ForegroundColor Yellow
  29. $identitySvcPathToPub = $scriptPath + "\pub\identity"
  30. Write-Host "identitySvcPathToPub is $identitySvcPathToPub" -ForegroundColor Yellow
  31. Write-Host "Restore Dependencies just in case as it is needed to run dotnet publish" -ForegroundColor Blue
  32. dotnet restore $identitySvcPathToJson
  33. dotnet build $identitySvcPathToJson
  34. dotnet publish $identitySvcPathToJson -o $identitySvcPathToPub
  35. #*** Catalog service image ***
  36. $catalogPathToJson = $scriptPath + "\src\Services\Catalog\Catalog.API\project.json"
  37. Write-Host "catalogPathToJson is $catalogPathToJson" -ForegroundColor Yellow
  38. $catalogPathToPub = $scriptPath + "\pub\catalog"
  39. Write-Host "catalogPathToPub is $catalogPathToPub" -ForegroundColor Yellow
  40. Write-Host "Restore Dependencies just in case as it is needed to run dotnet publish" -ForegroundColor Blue
  41. dotnet restore $catalogPathToJson
  42. dotnet build $catalogPathToJson
  43. dotnet publish $catalogPathToJson -o $catalogPathToPub
  44. #*** Ordering service image ***
  45. $orderingPath = $scriptPath + "\src\Services\Ordering"
  46. Write-Host "orderingPath is $orderingPath" -ForegroundColor Yellow
  47. $orderingApiPathToJson = $orderingPath + "\Ordering.API\project.json"
  48. Write-Host "orderingApiPathToJson is $orderingApiPathToJson" -ForegroundColor Yellow
  49. $orderingApiPathToPub = $scriptPath + "\pub\ordering"
  50. Write-Host "orderingApiPathToPub is $orderingApiPathToPub" -ForegroundColor Yellow
  51. Write-Host "Restore Dependencies just in case as it is needed to run dotnet publish" -ForegroundColor Blue
  52. dotnet restore $orderingPath
  53. dotnet build $orderingApiPathToJson
  54. dotnet publish $orderingApiPathToJson -o $orderingApiPathToPub
  55. #*** Basket service image ***
  56. $basketPathToJson = $scriptPath + "\src\Services\Basket\Basket.API\project.json"
  57. Write-Host "basketPathToJson is $basketPathToJson" -ForegroundColor Yellow
  58. $basketPathToPub = $scriptPath + "\pub\basket"
  59. Write-Host "basketPathToPub is $basketPathToPub" -ForegroundColor Yellow
  60. Write-Host "Restore Dependencies just in case as it is needed to run dotnet publish" -ForegroundColor Blue
  61. dotnet restore $basketPathToJson
  62. dotnet build $basketPathToJson
  63. dotnet publish $basketPathToJson -o $basketPathToPub
  64. $imagesToDelete = docker images --filter=reference="eshop/*" -q
  65. If (-Not $imagesToDelete) {Write-Host "Not deleting eShop images as there are no eShop images in the current local Docker repo."}
  66. Else
  67. {
  68. # Delete all containers
  69. Write-Host "Deleting all containers in local Docker Host"
  70. docker rm $(docker ps -a -q) -f
  71. # Delete all eshop images
  72. Write-Host "Deleting eShop images in local Docker repo"
  73. Write-Host $imagesToDelete
  74. docker rmi $(docker images --filter=reference="eshop/*" -q) -f
  75. }
  76. #*** build docker images ***
  77. docker build -t eshop/web $webPathToPub
  78. docker build -t eshop/catalog.api $catalogPathToPub
  79. docker build -t eshop/ordering.api $orderingApiPathToPub
  80. docker build -t eshop/basket.api $basketPathToPub
  81. docker build -t eshop/webspa $webSPAPathToPub
  82. docker build -t eshop/identity $identitySvcPathToPub