Skip to content

Commit

Permalink
Break install-all into phases to allow for some Docker layers (#346)
Browse files Browse the repository at this point in the history
Change env var helpers to write to USER env instead of SYSTEM env
  • Loading branch information
clarkb7 authored Feb 1, 2023
1 parent 9d44013 commit 4205bfa
Show file tree
Hide file tree
Showing 26 changed files with 58 additions and 33 deletions.
9 changes: 8 additions & 1 deletion windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions windows/helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -189,4 +189,4 @@ function Write-Variables() {
$targetfile = Get-VariableFile
$GlobalEnvVariables | convertto-json | set-content -path $targetfile

}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
72 changes: 46 additions & 26 deletions windows/install-all.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 4205bfa

Please sign in to comment.