From 4205bfa7184d5cd4089edbb2d1188d16c2b4aa11 Mon Sep 17 00:00:00 2001 From: Branden Clark Date: Wed, 1 Feb 2023 13:04:30 -0500 Subject: [PATCH] Break install-all into phases to allow for some Docker layers (#346) Change env var helpers to write to USER env instead of SYSTEM env --- windows/Dockerfile | 9 ++- windows/helpers.ps1 | 8 +-- windows/helpers/{ => phase1}/install_7zip.ps1 | 0 .../helpers/{ => phase1}/install_cmake.ps1 | 0 .../{ => phase1}/install_dotnetcore.ps1 | 0 .../helpers/{ => phase1}/install_mingit.ps1 | 0 .../helpers/{ => phase1}/install_net35.ps1 | 0 .../helpers/{ => phase1}/install_nuget.ps1 | 0 .../helpers/{ => phase1}/install_vcpkg.ps1 | 0 .../helpers/{ => phase1}/install_vcpython.ps1 | 0 .../helpers/{ => phase1}/install_vstudio.ps1 | 2 - windows/helpers/{ => phase1}/install_wdk.ps1 | 0 windows/helpers/{ => phase1}/install_wix.ps1 | 0 .../helpers/{ => phase2}/install_docker.ps1 | 0 .../{ => phase2}/install_embedded_pythons.ps1 | 0 .../{ => phase2}/install_gcloud_sdk.ps1 | 0 windows/helpers/{ => phase2}/install_msys.ps1 | 0 .../helpers/{ => phase2}/install_python.ps1 | 0 windows/helpers/{ => phase2}/install_ruby.ps1 | 0 .../helpers/{ => phase3}/install_codeql.ps1 | 0 windows/helpers/{ => phase3}/install_go.ps1 | 0 .../helpers/{ => phase3}/install_ibm_mq.ps1 | 0 .../helpers/{ => phase3}/install_ninja.ps1 | 0 .../helpers/{ => phase3}/install_winget.ps1 | 0 windows/helpers/phase4/.gitkeep.ps1 | 0 windows/install-all.ps1 | 72 ++++++++++++------- 26 files changed, 58 insertions(+), 33 deletions(-) rename windows/helpers/{ => phase1}/install_7zip.ps1 (100%) rename windows/helpers/{ => phase1}/install_cmake.ps1 (100%) rename windows/helpers/{ => phase1}/install_dotnetcore.ps1 (100%) rename windows/helpers/{ => phase1}/install_mingit.ps1 (100%) rename windows/helpers/{ => phase1}/install_net35.ps1 (100%) rename windows/helpers/{ => phase1}/install_nuget.ps1 (100%) rename windows/helpers/{ => phase1}/install_vcpkg.ps1 (100%) rename windows/helpers/{ => phase1}/install_vcpython.ps1 (100%) rename windows/helpers/{ => phase1}/install_vstudio.ps1 (96%) rename windows/helpers/{ => phase1}/install_wdk.ps1 (100%) rename windows/helpers/{ => phase1}/install_wix.ps1 (100%) rename windows/helpers/{ => phase2}/install_docker.ps1 (100%) rename windows/helpers/{ => phase2}/install_embedded_pythons.ps1 (100%) rename windows/helpers/{ => phase2}/install_gcloud_sdk.ps1 (100%) rename windows/helpers/{ => phase2}/install_msys.ps1 (100%) rename windows/helpers/{ => phase2}/install_python.ps1 (100%) rename windows/helpers/{ => phase2}/install_ruby.ps1 (100%) rename windows/helpers/{ => phase3}/install_codeql.ps1 (100%) rename windows/helpers/{ => phase3}/install_go.ps1 (100%) rename windows/helpers/{ => phase3}/install_ibm_mq.ps1 (100%) rename windows/helpers/{ => phase3}/install_ninja.ps1 (100%) rename windows/helpers/{ => phase3}/install_winget.ps1 (100%) create mode 100644 windows/helpers/phase4/.gitkeep.ps1 diff --git a/windows/Dockerfile b/windows/Dockerfile index 49e137e7d..3a419e756 100644 --- a/windows/Dockerfile +++ b/windows/Dockerfile @@ -65,7 +65,14 @@ COPY ./requirements.txt ./requirements-py2.txt / COPY ./python-packages-versions.txt /python-packages-versions.txt COPY ./windows/set_cpython_compiler.cmd set_cpython_compiler.cmd -RUN .\install-all.ps1 -TargetContainer +COPY ./windows/helpers/phase1/*.ps1 c:/scripts/helpers/phase1/ +RUN .\install-all.ps1 -TargetContainer -Phase 1 +COPY ./windows/helpers/phase2/*.ps1 c:/scripts/helpers/phase2/ +RUN .\install-all.ps1 -TargetContainer -Phase 2 +COPY ./windows/helpers/phase3/*.ps1 c:/scripts/helpers/phase3/ +RUN .\install-all.ps1 -TargetContainer -Phase 3 +COPY ./windows/helpers/phase4/*.ps1 c:/scripts/helpers/phase4/ +RUN .\install-all.ps1 -TargetContainer -Phase 4 COPY ./windows/entrypoint.bat /entrypoint.bat COPY ./windows/helpers/aws_networking.ps1 /aws_networking.ps1 diff --git a/windows/helpers.ps1 b/windows/helpers.ps1 index 3b55786d3..ed7b79df2 100644 --- a/windows/helpers.ps1 +++ b/windows/helpers.ps1 @@ -84,7 +84,7 @@ function Add-EnvironmentVariable() { } if($Global){ if($TargetContainer){ - [Environment]::SetEnvironmentVariable($Variable, $Value, [System.EnvironmentVariableTarget]::Machine) + [Environment]::SetEnvironmentVariable($Variable, $Value, [System.EnvironmentVariableTarget]::User) } else { $GlobalEnvVariables.EnvironmentVars[$($Variable)] = $Value } @@ -106,9 +106,9 @@ function Add-ToPath() { } if($Global){ if($TargetContainer){ - $oldPath=[Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine) + $oldPath=[Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User) $target="$oldPath;$NewPath" - [Environment]::SetEnvironmentVariable("Path", $target, [System.EnvironmentVariableTarget]::Machine) + [Environment]::SetEnvironmentVariable("Path", $target, [System.EnvironmentVariableTarget]::User) } else { if ($GlobalEnvVariables.PathEntries -notcontains $NewPath){ $GlobalEnvVariables.PathEntries += $NewPath @@ -189,4 +189,4 @@ function Write-Variables() { $targetfile = Get-VariableFile $GlobalEnvVariables | convertto-json | set-content -path $targetfile -} \ No newline at end of file +} diff --git a/windows/helpers/install_7zip.ps1 b/windows/helpers/phase1/install_7zip.ps1 similarity index 100% rename from windows/helpers/install_7zip.ps1 rename to windows/helpers/phase1/install_7zip.ps1 diff --git a/windows/helpers/install_cmake.ps1 b/windows/helpers/phase1/install_cmake.ps1 similarity index 100% rename from windows/helpers/install_cmake.ps1 rename to windows/helpers/phase1/install_cmake.ps1 diff --git a/windows/helpers/install_dotnetcore.ps1 b/windows/helpers/phase1/install_dotnetcore.ps1 similarity index 100% rename from windows/helpers/install_dotnetcore.ps1 rename to windows/helpers/phase1/install_dotnetcore.ps1 diff --git a/windows/helpers/install_mingit.ps1 b/windows/helpers/phase1/install_mingit.ps1 similarity index 100% rename from windows/helpers/install_mingit.ps1 rename to windows/helpers/phase1/install_mingit.ps1 diff --git a/windows/helpers/install_net35.ps1 b/windows/helpers/phase1/install_net35.ps1 similarity index 100% rename from windows/helpers/install_net35.ps1 rename to windows/helpers/phase1/install_net35.ps1 diff --git a/windows/helpers/install_nuget.ps1 b/windows/helpers/phase1/install_nuget.ps1 similarity index 100% rename from windows/helpers/install_nuget.ps1 rename to windows/helpers/phase1/install_nuget.ps1 diff --git a/windows/helpers/install_vcpkg.ps1 b/windows/helpers/phase1/install_vcpkg.ps1 similarity index 100% rename from windows/helpers/install_vcpkg.ps1 rename to windows/helpers/phase1/install_vcpkg.ps1 diff --git a/windows/helpers/install_vcpython.ps1 b/windows/helpers/phase1/install_vcpython.ps1 similarity index 100% rename from windows/helpers/install_vcpython.ps1 rename to windows/helpers/phase1/install_vcpython.ps1 diff --git a/windows/helpers/install_vstudio.ps1 b/windows/helpers/phase1/install_vstudio.ps1 similarity index 96% rename from windows/helpers/install_vstudio.ps1 rename to windows/helpers/phase1/install_vstudio.ps1 index bdb9e0158..90c8d673a 100644 --- a/windows/helpers/install_vstudio.ps1 +++ b/windows/helpers/phase1/install_vstudio.ps1 @@ -22,9 +22,7 @@ $VSPackages = @( "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre", "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81", -# "Microsoft.VisualStudio.Component.Windows10SDK.17763", "Microsoft.VisualStudio.Component.Windows10SDK.18362" -# "Microsoft.VisualStudio.Component.Windows10SDK.19041" ) $VSPackagesDesktop = @( diff --git a/windows/helpers/install_wdk.ps1 b/windows/helpers/phase1/install_wdk.ps1 similarity index 100% rename from windows/helpers/install_wdk.ps1 rename to windows/helpers/phase1/install_wdk.ps1 diff --git a/windows/helpers/install_wix.ps1 b/windows/helpers/phase1/install_wix.ps1 similarity index 100% rename from windows/helpers/install_wix.ps1 rename to windows/helpers/phase1/install_wix.ps1 diff --git a/windows/helpers/install_docker.ps1 b/windows/helpers/phase2/install_docker.ps1 similarity index 100% rename from windows/helpers/install_docker.ps1 rename to windows/helpers/phase2/install_docker.ps1 diff --git a/windows/helpers/install_embedded_pythons.ps1 b/windows/helpers/phase2/install_embedded_pythons.ps1 similarity index 100% rename from windows/helpers/install_embedded_pythons.ps1 rename to windows/helpers/phase2/install_embedded_pythons.ps1 diff --git a/windows/helpers/install_gcloud_sdk.ps1 b/windows/helpers/phase2/install_gcloud_sdk.ps1 similarity index 100% rename from windows/helpers/install_gcloud_sdk.ps1 rename to windows/helpers/phase2/install_gcloud_sdk.ps1 diff --git a/windows/helpers/install_msys.ps1 b/windows/helpers/phase2/install_msys.ps1 similarity index 100% rename from windows/helpers/install_msys.ps1 rename to windows/helpers/phase2/install_msys.ps1 diff --git a/windows/helpers/install_python.ps1 b/windows/helpers/phase2/install_python.ps1 similarity index 100% rename from windows/helpers/install_python.ps1 rename to windows/helpers/phase2/install_python.ps1 diff --git a/windows/helpers/install_ruby.ps1 b/windows/helpers/phase2/install_ruby.ps1 similarity index 100% rename from windows/helpers/install_ruby.ps1 rename to windows/helpers/phase2/install_ruby.ps1 diff --git a/windows/helpers/install_codeql.ps1 b/windows/helpers/phase3/install_codeql.ps1 similarity index 100% rename from windows/helpers/install_codeql.ps1 rename to windows/helpers/phase3/install_codeql.ps1 diff --git a/windows/helpers/install_go.ps1 b/windows/helpers/phase3/install_go.ps1 similarity index 100% rename from windows/helpers/install_go.ps1 rename to windows/helpers/phase3/install_go.ps1 diff --git a/windows/helpers/install_ibm_mq.ps1 b/windows/helpers/phase3/install_ibm_mq.ps1 similarity index 100% rename from windows/helpers/install_ibm_mq.ps1 rename to windows/helpers/phase3/install_ibm_mq.ps1 diff --git a/windows/helpers/install_ninja.ps1 b/windows/helpers/phase3/install_ninja.ps1 similarity index 100% rename from windows/helpers/install_ninja.ps1 rename to windows/helpers/phase3/install_ninja.ps1 diff --git a/windows/helpers/install_winget.ps1 b/windows/helpers/phase3/install_winget.ps1 similarity index 100% rename from windows/helpers/install_winget.ps1 rename to windows/helpers/phase3/install_winget.ps1 diff --git a/windows/helpers/phase4/.gitkeep.ps1 b/windows/helpers/phase4/.gitkeep.ps1 new file mode 100644 index 000000000..e69de29bb diff --git a/windows/install-all.ps1 b/windows/install-all.ps1 index b261ba1d1..777a5b3b2 100644 --- a/windows/install-all.ps1 +++ b/windows/install-all.ps1 @@ -1,5 +1,6 @@ param( - [Parameter(Mandatory = $false)][switch] $TargetContainer + [Parameter(Mandatory = $false)][switch] $TargetContainer, + [Parameter(Mandatory = $false)][string] $Phase = "0" ) [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 @@ -38,32 +39,51 @@ if($TargetContainer){ } try { - .\helpers\install_net35.ps1 - .\helpers\install_7zip.ps1 -Version $ENV:SEVENZIP_VERSION -Sha256 $ENV:SEVENZIP_SHA256 - .\helpers\install_vstudio.ps1 #-Version $ENV:VS2017BUILDTOOLS_VERSION -Sha256 $ENV:VS2017BUILDTOOLS_SHA256 $ENV:VS2017BUILDTOOLS_DOWNLOAD_URL - .\helpers\install_mingit.ps1 -Version $ENV:GIT_VERSION -Sha256 $ENV:GIT_SHA256 + # Each phase is its own layer in the Dockerfile, to make it easier to iterate on changes + # by making use of Docker's layer cache. The phases are roughly organized by dependencies, + # install time, and frequency of updates, with longer install times and less frequently + # changed items in the earlier phases. + # + # Phase 4 is empty by default. Before starting work on updating an item move the script to Phase 4. + # + if ($Phase -eq 0 -or $Phase -eq 1) { + .\helpers\phase1\install_net35.ps1 + .\helpers\phase1\install_7zip.ps1 -Version $ENV:SEVENZIP_VERSION -Sha256 $ENV:SEVENZIP_SHA256 + .\helpers\phase1\install_mingit.ps1 -Version $ENV:GIT_VERSION -Sha256 $ENV:GIT_SHA256 + .\helpers\phase1\install_vstudio.ps1 + .\helpers\phase1\install_wdk.ps1 + .\helpers\phase1\install_wix.ps1 -Version $ENV:WIX_VERSION -Sha256 $ENV:WIX_SHA256 + .\helpers\phase1\install_dotnetcore.ps1 + .\helpers\phase1\install_nuget.ps1 -Version $ENV:NUGET_VERSION -Sha256 $ENV:NUGET_SHA256 + .\helpers\phase1\install_vcpython.ps1 + .\helpers\phase1\install_cmake.ps1 -Version $ENV:CMAKE_VERSION -Sha256 $ENV:CMAKE_SHA256 + # # vcpkg depends on cmake + .\helpers\phase1\install_vcpkg.ps1 + } + + if ($Phase -eq 0 -or $Phase -eq 2) { + .\helpers\phase2\install_docker.ps1 + .\helpers\phase2\install_ruby.ps1 -Version $ENV:RUBY_VERSION -Sha256 $ENV:RUBY_SHA256 + # msys depends on ruby + .\helpers\phase2\install_msys.ps1 -Version $ENV:MSYS_VERSION -Sha256 $ENV:MSYS_SHA256 + .\helpers\phase2\install_python.ps1 -Version $ENV:PYTHON_VERSION -Sha256 $ENV:PYTHON_SHA256 + .\helpers\phase2\install_gcloud_sdk.ps1 + .\helpers\phase2\install_embedded_pythons.ps1 + } - .\helpers\install_wdk.ps1 - .\helpers\install_wix.ps1 -Version $ENV:WIX_VERSION -Sha256 $ENV:WIX_SHA256 - .\helpers\install_dotnetcore.ps1 - .\helpers\install_nuget.ps1 -Version $ENV:NUGET_VERSION -Sha256 $ENV:NUGET_SHA256 - .\helpers\install_vcpython.ps1 - .\helpers\install_ibm_mq.ps1 -Version $ENV:IBM_MQ_VERSION -Sha256 $ENV:IBM_MQ_SHA256 - .\helpers\install_cmake.ps1 -Version $ENV:CMAKE_VERSION -Sha256 $ENV:CMAKE_SHA256 - .\helpers\install_winget.ps1 -Version $ENV:WINGET_VERSION -Sha256 $ENV:WINGET_SHA256 - .\helpers\install_go.ps1 - .\helpers\install_python.ps1 -Version $ENV:PYTHON_VERSION -Sha256 $ENV:PYTHON_SHA256 - .\helpers\install_ruby.ps1 -Version $ENV:RUBY_VERSION -Sha256 $ENV:RUBY_SHA256 - .\helpers\install_msys.ps1 -Version $ENV:MSYS_VERSION -Sha256 $ENV:MSYS_SHA256 - .\helpers\install_docker.ps1 - .\helpers\install_gcloud_sdk.ps1 - .\helpers\install_embedded_pythons.ps1 - .\helpers\install_vcpkg.ps1 - .\helpers\install_codeql.ps1 - .\helpers\install_ninja.ps1 -Version $ENV:NINJA_VERSION -Sha256 $ENV:NINJA_SHA256 - ## # Add signtool to path - Add-ToPath -NewPath "${env:ProgramFiles(x86)}\Windows Kits\8.1\bin\x64\" -Global - & .\set_cpython_compiler.cmd + if ($Phase -eq 0 -or $Phase -eq 3) { + .\helpers\phase3\install_ibm_mq.ps1 -Version $ENV:IBM_MQ_VERSION -Sha256 $ENV:IBM_MQ_SHA256 + .\helpers\phase3\install_winget.ps1 -Version $ENV:WINGET_VERSION -Sha256 $ENV:WINGET_SHA256 + .\helpers\phase3\install_go.ps1 + .\helpers\phase3\install_codeql.ps1 + .\helpers\phase3\install_ninja.ps1 -Version $ENV:NINJA_VERSION -Sha256 $ENV:NINJA_SHA256 + ## # Add signtool to path + Add-ToPath -NewPath "${env:ProgramFiles(x86)}\Windows Kits\8.1\bin\x64\" -Global + & .\set_cpython_compiler.cmd + } + + if ($Phase -eq 0 -or $Phase -eq 4) { + } } catch { Write-Host -ForegroundColor Red "Error installing software"