-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[windows] Reduce size of Windows images #47
Open
KSerrania
wants to merge
10
commits into
main
Choose a base branch
from
kserrania/windows-less-layers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+208
−148
Open
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c0d1314
Reduce number of layers
KSerrania 53f4d5b
Reorganize Dockerfiles
KSerrania 87cc565
Use bundled 3.5 and 4.8 on 1909
KSerrania 81c4916
Try even less layers
KSerrania 9fa3bc4
Correct entrypoint
KSerrania b98cddb
Update comments
KSerrania 320d4b9
Add checks
KSerrania 8ec90fe
Split long lines
KSerrania 59a51e7
Merge remote-tracking branch 'origin/master' into kserrania/windows-l…
KSerrania 0c0ebad
Merge branch 'master' into kserrania/windows-less-layers
KSerrania File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
$ErrorActionPreference = 'Stop' | ||
|
||
function Code-Check { | ||
param ($Code, $Element) | ||
if ($Code -ne 0) { | ||
Write-Host -ForegroundColor Red "$Element install failed" | ||
[Environment]::Exit(1) | ||
} | ||
} | ||
|
||
# git, ridk and bundler aren't available yet right after they're installed, you need to restart a shell | ||
|
||
### HACK: we disable symbolic links when cloning repositories | ||
### to work around a symlink-related failure in the agent-binaries omnibus project | ||
### when copying the datadog-agent project twice. | ||
git config --system core.symlinks false | ||
|
||
# Install 64-bit C/C++ compilation toolchain | ||
ridk install 3 | ||
Code-Check -Code $LASTEXITCODE -Element "ridk" | ||
|
||
|
||
setx RIDK ((Get-Command ridk).Path) | ||
|
||
# (32-bit only) Install 32-bit C/C++ compilation toolchain | ||
if ($Env:TARGET_ARCH -eq 'x86') { ridk enable; bash -c "pacman -S --needed --noconfirm mingw-w64-i686-binutils mingw-w64-i686-crt-git mingw-w64-i686-gcc mingw-w64-i686-gcc-libs mingw-w64-i686-headers-git mingw-w64-i686-libmangle-git mingw-w64-i686-libwinpthread-git mingw-w64-i686-make mingw-w64-i686-pkg-config mingw-w64-i686-tools-git mingw-w64-i686-winpthreads-git" } | ||
Code-Check -Code $LASTEXITCODE -Element "32-bit ridk" | ||
|
||
|
||
if ($Env:TARGET_ARCH -eq 'x86') { [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\tools\msys64\mingw32\bin;C:\tools\msys64\usr\bin", [System.EnvironmentVariableTarget]::Machine) } | ||
|
||
# Install bundler for omnibus builds | ||
gem install bundler | ||
Code-Check -Code $LASTEXITCODE -Element "bundler" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
$ErrorActionPreference = 'Stop' | ||
|
||
function Code-Check { | ||
param ($Code, $Element) | ||
if ($Code -ne 0) { | ||
Write-Host -ForegroundColor Red "$Element install failed" | ||
[Environment]::Exit(1) | ||
} | ||
} | ||
|
||
# Add certificates needed for build & check certificates file hash | ||
# We need to trust the DigiCert High Assurance EV Root CA certificate, which signs python.org, | ||
# to be able to download some Python components during the Agent build. | ||
(New-Object System.Net.WebClient).DownloadFile("https://curl.haxx.se/ca/cacert.pem", "cacert.pem") | ||
if ((Get-FileHash .\cacert.pem).Hash -ne "$ENV:CACERTS_HASH") { Write-Host "Wrong hashsum for cacert.pem: got '$((Get-FileHash .\cacert.pem).Hash)', expected '$ENV:CACERTS_HASH'."; exit 1 } | ||
setx SSL_CERT_FILE "C:\cacert.pem" | ||
|
||
# Set 32-bit flag env var | ||
if ($Env:TARGET_ARCH -eq 'x86') { setx CHOCO_ARCH_FLAG '-x86' ; setx WINDOWS_BUILD_32_BIT 1 } | ||
|
||
# Install Chocolatey | ||
$env:chocolateyUseWindowsCompression = 'true'; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | ||
Code-Check -Code $LASTEXITCODE -Element "chocolatey" | ||
|
||
|
||
# Install git | ||
$env:chocolateyUseWindowsCompression = 'true'; cinst -y --no-progress git $ENV:CHOCO_ARCH_FLAG --version $ENV:GIT_VERSION | ||
Code-Check -Code $LASTEXITCODE -Element "git" | ||
|
||
|
||
# Install 7zip | ||
$env:chocolateyUseWindowsCompression = 'true'; cinst -y --no-progress 7zip $ENV:CHOCO_ARCH_FLAG --version $ENV:SEVENZIP_VERSION | ||
Code-Check -Code $LASTEXITCODE -Element "7zip" | ||
|
||
|
||
# Install Cmake and update PATH to include it | ||
cinst -y --no-progress cmake $ENV:CHOCO_ARCH_FLAG --version $ENV:CMAKE_VERSION | ||
Code-Check -Code $LASTEXITCODE -Element "cmake" | ||
|
||
|
||
if ($Env:TARGET_ARCH -eq 'x86') { [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";${Env:ProgramFiles(x86)}\CMake\bin", [System.EnvironmentVariableTarget]::Machine) } | ||
if ($Env:TARGET_ARCH -eq 'x64') { [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";${env:ProgramFiles}\CMake\bin", [System.EnvironmentVariableTarget]::Machine) } | ||
|
||
# Install golang and set GOPATH to the dev path used in builds & tests | ||
cinst -y --no-progress golang $ENV:CHOCO_ARCH_FLAG --version $ENV:GO_VERSION | ||
Code-Check -Code $LASTEXITCODE -Element "golang" | ||
|
||
|
||
setx GOPATH C:\dev\go | ||
|
||
# Install system Python 2 (to use invoke) | ||
cinst -y --no-progress python2 $ENV:CHOCO_ARCH_FLAG --version $ENV:PYTHON_VERSION | ||
Code-Check -Code $LASTEXITCODE -Element "python2" | ||
|
||
|
||
# Install 64-bit ruby (for omnibus builds) | ||
cinst -y --no-progress ruby --version $ENV:RUBY_VERSION | ||
Code-Check -Code $LASTEXITCODE -Element "ruby" | ||
|
||
|
||
### We need both the .NET 3.5 runtime and the .NET 4.8 runtime. | ||
### To do this, on 1809 we get 4.8 from a base image and we | ||
### manually the install .NET Framework 3.5 runtime using the instructions in | ||
### the mcr.microsoft.com/dotnet/framework/runtime:3.5 Dockerfile: | ||
### https://github.com/microsoft/dotnet-framework-docker/blob/26597e42d157cc1e09d1e0dc8f23c32e6c3d1467/3.5/runtime/windowsservercore-ltsc2019/Dockerfile | ||
|
||
### 1909 includes .NET Framework 4.8 by default, so we use the image that includes | ||
### .NET Framework 3.5 as well, and thus we don't need to install it manually here. | ||
|
||
### The .NET Fx 3.5 is needed for the Visual C++ Compiler for Python 2.7 | ||
### (https://www.microsoft.com/en-us/download/details.aspx?id=44266) | ||
### and to work around a bug in the WiX 3.11 installer | ||
### (https://github.com/wixtoolset/issues/issues/5661). | ||
|
||
# Install .NET Fx 3.5 | ||
if ($Env:WINDOWS_VERSION -eq '1809') { .\scripts\install_net35_1809.bat } | ||
Code-Check -Code $LASTEXITCODE -Element ".NET 3.5" | ||
|
||
|
||
# Install VS2017 | ||
cinst -y --no-progress visualstudio2017buildtools $ENV:CHOCO_ARCH_FLAG --version $ENV:VS2017BUILDTOOLS_VERSION --params "--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81 --add Microsoft.VisualStudio.Workload.VCTools" | ||
Code-Check -Code $LASTEXITCODE -Element "visualstudio2017buildtools" | ||
|
||
|
||
setx VSTUDIO_ROOT "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools" | ||
|
||
# Add signtool to path | ||
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";${env:ProgramFiles(x86)}\Windows Kits\8.1\bin\x64", [System.EnvironmentVariableTarget]::Machine) | ||
|
||
# Install VC compiler for Python 2.7 | ||
cinst -y --no-progress vcpython27 $ENV:CHOCO_ARCH_FLAG --version $ENV:VCPYTHON27_VERSION | ||
Code-Check -Code $LASTEXITCODE -Element "vcpython27" | ||
|
||
|
||
# Install Wix and update PATH to include it | ||
cinst -y --no-progress wixtoolset $ENV:CHOCO_ARCH_FLAG --version $ENV:WIX_VERSION | ||
Code-Check -Code $LASTEXITCODE -Element "wixtoolset" | ||
|
||
|
||
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";${env:ProgramFiles(x86)}\WiX Toolset v3.11\bin", [System.EnvironmentVariableTarget]::Machine) | ||
|
||
# Install msys2 system | ||
cinst -y --no-progress msys2 --params "/NoUpdate" --version $ENV:MSYS_VERSION | ||
Code-Check -Code $LASTEXITCODE -Element "msys2" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think it could help legibility to format long lines over multiple lines