mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-08-17 20:11:00 +02:00
Updated build process for Zabbix agent (windows)
This commit is contained in:
@@ -1,27 +1,37 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# escape=`
|
||||
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
|
||||
FROM $BUILD_BASE_IMAGE
|
||||
FROM $BUILD_BASE_IMAGE as builder_base
|
||||
|
||||
ARG PCRE_VERSION=8.45
|
||||
ARG OPENSSL_VERSION=1.1.1s
|
||||
ARG ZLIB_VERSION=1.3.1
|
||||
ARG CURL_VERSION=8.7.1
|
||||
|
||||
ARG BUILD_ARCH=x64
|
||||
ARG CPU_MODEL=AMD64
|
||||
|
||||
ARG MAJOR_VERSION=5.0
|
||||
ARG ZBX_VERSION=${MAJOR_VERSION}.42
|
||||
|
||||
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/16/release/vs_buildtools.exe
|
||||
ARG NASM_URL=https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/nasm-2.15.05-installer-x64.exe
|
||||
ARG PERL_URL=https://strawberryperl.com/download/5.32.1.1/strawberry-perl-5.32.1.1-64bit.msi
|
||||
ARG GIT_URL=https://github.com/git-for-windows/git/releases/download/v2.33.0.windows.2/MinGit-2.33.0.2-busybox-64-bit.zip
|
||||
ARG PERL_URL=https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_53822_64bit/strawberry-perl-5.38.2.2-64bit-portable.zip
|
||||
|
||||
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/17/release/vs_buildtools.exe
|
||||
ARG NASM_URL=https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-installer-x64.exe
|
||||
|
||||
ARG PCRE_URL=https://sourceforge.net/projects/pcre/files/pcre/$PCRE_VERSION/pcre-$PCRE_VERSION.zip
|
||||
ARG OPENSSL_URL=https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
|
||||
ARG ZLIB_URL=https://zlib.net/zlib-$ZLIB_VERSION.tar.gz
|
||||
ARG CURL_URL=https://curl.se/download/curl-$CURL_VERSION.tar.gz
|
||||
|
||||
ENV ZBX_VERSION=$ZBX_VERSION `
|
||||
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
|
||||
GIT_URL=$GIT_URL PERL_URL=$PERL_URL NASM_URL=$NASM_URL `
|
||||
VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL `
|
||||
PCRE_VERSION=$PCRE_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
|
||||
GIT_URL=$GIT_URL NASM_URL=$NASM_URL PERL_URL=$PERL_URL PCRE_URL=$PCRE_URL OPENSSL_URL=$OPENSSL_URL
|
||||
PCRE_URL=$PCRE_URL OPENSSL_URL=$OPENSSL_URL `
|
||||
ZLIB_URL=$ZLIB_URL CURL_URL=$CURL_URL
|
||||
|
||||
LABEL org.opencontainers.image.title="Zabbix agent build base for Windows" `
|
||||
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
||||
@@ -35,94 +45,86 @@ LABEL org.opencontainers.image.title="Zabbix agent build base for Windows" `
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
`
|
||||
$env:PATH = [string]::Format('{0}\perl\perl\bin;{1}\NASM;{0}\git\cmd;{0}\git\mingw64\bin;{0}\git\usr\bin;', $env:SystemDrive, ${env:ProgramFiles}) + $env:PATH; `
|
||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
$env:BUILD_OUTPUT = [string]::Format('{0}\build_output', $env:SystemDrive); `
|
||||
[Environment]::SetEnvironmentVariable('BUILD_OUTPUT', $env:BUILD_OUTPUT, [EnvironmentVariableTarget]::Machine); `
|
||||
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
|
||||
[Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:GIT_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\git.zip -Uri $env:GIT_URL; `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\git.zip -Uri $env:GIT_URL; `
|
||||
`
|
||||
$sha256 = '273f55e881094d00877d64f56570b0c997c4da5dedcb26738d56481033c1eba1'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\git.zip -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\git.zip -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum GIT for Windows failed!'; `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum GIT for Windows ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Installing ...'; `
|
||||
Write-Host ('Downloading {0} ...' -f $env:NASM_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\nasm_installer.exe -Uri $env:NASM_URL; `
|
||||
`
|
||||
$sha256 = '657E1252676CFB26A008835C20A760F731C8E0414469A4ED0F83F0FB059CDD35'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\nasm_installer.exe -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:TEMP\nasm_installer.exe -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host ('Checksum NASM ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:PERL_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\perl.zip -Uri $env:PERL_URL; `
|
||||
`
|
||||
$sha256 = 'EA451686065D6338D7E4D4A04C9AF49F17951D15AA4C2E19AB8CB56FA2373440'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\perl.zip -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum Strawberry Perl ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; `
|
||||
`
|
||||
Write-Host 'Installing GIT...'; `
|
||||
Expand-Archive `
|
||||
-Path git.zip `
|
||||
-Path $env:TEMP\git.zip `
|
||||
-DestinationPath $env:SystemDrive\git\.; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\git.zip; `
|
||||
$env:PATH = [string]::Format('{0}\git\cmd;{0}\git\mingw64\bin;{0}\git\usr\bin;', $env:SystemDrive) + $env:PATH; `
|
||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
Write-Host 'Verifying install ("git version") ...'; `
|
||||
git version; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:NASM_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\nasm_installer.exe -Uri $env:NASM_URL; `
|
||||
$sha256 = 'a02325b9fe54f917f5d6a3036637b38dbb6addf6f7ba9d344d9b943a143fe7d0'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\nasm_installer.exe -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum NASM failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
Write-Host 'Installing ...'; `
|
||||
Write-Host 'Installing NASM...'; `
|
||||
Start-Process `
|
||||
-FilePath $env:SystemDrive\nasm_installer.exe `
|
||||
-FilePath $env:TEMP\nasm_installer.exe `
|
||||
-ArgumentList '/S' -Wait; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\nasm_installer.exe; `
|
||||
`
|
||||
$env:PATH = [string]::Format('{0}\NASM;', ${env:ProgramFiles}) + $env:PATH; `
|
||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
Write-Host 'Verifying install ("nasm -v") ...'; `
|
||||
nasm -v; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:PERL_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\perl_installer.msi -Uri $env:PERL_URL; `
|
||||
`
|
||||
$sha256 = '241a881670164feb0b91bb69d39fbbf84c981bec0d9f8c19959f8f48fd177768'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\perl_installer.msi -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum Strawberry Perl failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
Write-Host 'Installing ...'; `
|
||||
Start-Process `
|
||||
-FilePath 'msiexec.exe' `
|
||||
-ArgumentList """/i $env:SystemDrive\perl_installer.msi /qn /norestart INSTALLDIR=$env:SystemDrive\Strawberry""" `
|
||||
-Wait; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\perl_installer.msi; `
|
||||
$env:PATH = [string]::Format('{0}\Strawberry\perl\bin;', $env:SystemDrive) + $env:PATH; `
|
||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
Write-Host 'Installing Perl...'; `
|
||||
Expand-Archive -Path $env:TEMP\perl.zip -DestinationPath $env:SystemDrive\perl\; `
|
||||
Remove-Item -Force -Recurse $env:SystemDrive\perl\c\; `
|
||||
`
|
||||
Write-Host 'Verifying install ("perl -V") ...'; `
|
||||
perl -V; `
|
||||
`
|
||||
Write-Host 'Installing Text::Template...'; `
|
||||
cpan Text::Template; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; `
|
||||
`
|
||||
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
|
||||
cmd /C start /w $env:SystemDrive\vs_buildtools.exe `
|
||||
cmd /C start /w $env:TEMP\vs_buildtools.exe `
|
||||
--quiet `
|
||||
--wait `
|
||||
--norestart `
|
||||
--nocache `
|
||||
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\BuildTools""" `
|
||||
--channelUri https://aka.ms/vs/16/release/channel `
|
||||
--installChannelUri https://aka.ms/vs/16/release/channel `
|
||||
--channelId VisualStudio.16.Release `
|
||||
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019
|
||||
--add Microsoft.VisualStudio.Component.Windows10SDK.19041 `
|
||||
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" `
|
||||
--channelUri https://aka.ms/vs/17/release/channel `
|
||||
--installChannelUri https://aka.ms/vs/17/release/channel `
|
||||
--channelId VisualStudio.17.Release `
|
||||
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
|
||||
--add Microsoft.VisualStudio.Component.Windows11SDK.22621 `
|
||||
--add Microsoft.VisualStudio.Component.VC.CMake.Project; `
|
||||
if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { `
|
||||
throw $err; `
|
||||
@@ -130,40 +132,127 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
Wait-Process -name msiexec; `
|
||||
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
|
||||
`
|
||||
Write-Host 'Visual Studio components installation cleanup'; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\vs_buildtools.exe; `
|
||||
Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; `
|
||||
Remove-Item -Force -Recurse $env:TEMP\*; `
|
||||
Write-Host 'Build environment is ready...';
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
$env:VS_PATH = &(Join-Path ${env:ProgramFiles(x86)} """\Microsoft Visual Studio\Installer\vswhere.exe""") -latest -products Microsoft.VisualStudio.Product.BuildTools -property installationPath; `
|
||||
[Environment]::SetEnvironmentVariable('VS_PATH', $env:VS_PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
Import-Module ('{0}\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -f ${env:ProgramFiles(x86)} ); `
|
||||
Enter-VsDevShell -VsInstallPath ('{0}\Microsoft Visual Studio\2019\BuildTools' -f ${env:ProgramFiles(x86)}) -DevCmdArguments """-arch=$env:BUILD_ARCH"""; `
|
||||
Write-Host 'Visual Studio components installation cleanup'; `
|
||||
Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Recurse $env:TEMP\*; `
|
||||
Write-Host 'Build environment is ready...'; `
|
||||
`
|
||||
Set-Location -Path $env:SystemDrive\.; `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
`
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; `
|
||||
Set-Location -Path $env:BUILD_SRC; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:PCRE_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
(new-object System.Net.WebClient).DownloadFile("""$env:PCRE_URL""","""$env:SystemDrive\pcre.zip"""); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\pcre.zip -Uri $env:PCRE_URL; `
|
||||
`
|
||||
$sha256 = '5b709aa45ea3b8bb73052947200ad187f651a2049158fb5bbfed329e4322a977'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\pcre.zip -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\pcre.zip -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum PCRE library failed!'; `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum PCRE library ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
Write-Host 'Extracting archive ...'; `
|
||||
Expand-Archive -Path $env:SystemDrive\pcre.zip -DestinationPath $env:SystemDrive; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\pcre.zip; `
|
||||
Rename-Item -Path $env:SystemDrive\pcre-$env:PCRE_VERSION -NewName $env:SystemDrive\pcre_build; `
|
||||
New-Item -ItemType directory -Path "$env:SystemDrive\pcre_build\build" | Out-Null; `
|
||||
`
|
||||
Set-Location -Path $env:SystemDrive\pcre_build\build; `
|
||||
Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\openssl.tar.gz -Uri $env:OPENSSL_URL; `
|
||||
`
|
||||
$sha256 = '6ae015467dabf0469b139ada93319327be24b98251ffaeceda0221848dc09262'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\openssl.tar.gz -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum OpenSSL library ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:ZLIB_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\zlib.tar.gz -Uri $env:ZLIB_URL; `
|
||||
`
|
||||
$sha256 = '9A93B2B7DFDAC77CEBA5A558A580E74667DD6FEDE4585B91EEFB60F03B72DF23'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\zlib.tar.gz -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum Zlib library ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:CURL_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\curl.tar.gz -Uri $env:CURL_URL; `
|
||||
`
|
||||
$sha256 = 'F91249C87F68EA00CF27C44FDFA5A78423E41E71B7D408E5901A9896D905C495'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\curl.tar.gz -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum Curl library ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Extracting PCRE archive ...'; `
|
||||
Expand-Archive -Path $env:TEMP\pcre.zip -DestinationPath $env:BUILD_SRC; `
|
||||
Rename-Item -Path $env:BUILD_SRC\pcre-$env:PCRE_VERSION -NewName $env:BUILD_SRC\pcre; `
|
||||
New-Item -ItemType directory -Path "$env:BUILD_SRC\pcre\build" | Out-Null; `
|
||||
`
|
||||
Write-Host 'Extracting OpenSSL archive ...'; `
|
||||
tar -zxf $env:TEMP\openssl.tar.gz; `
|
||||
Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; `
|
||||
`
|
||||
Write-Host 'Extracting Zlib archive ...'; `
|
||||
tar -zxf $env:TEMP\zlib.tar.gz; `
|
||||
Move-Item -Path $env:BUILD_SRC\zlib-$env:ZLIB_VERSION\ -Destination $env:BUILD_SRC\zlib; `
|
||||
`
|
||||
Write-Host 'Extracting CURL archive ...'; `
|
||||
tar -zxf $env:TEMP\curl.tar.gz; `
|
||||
Move-Item -Path $env:BUILD_SRC\curl-$env:CURL_VERSION\ -Destination $env:BUILD_SRC\curl; `
|
||||
`
|
||||
Set-Location -Path $env:SystemDrive\.; `
|
||||
`
|
||||
Import-Module (Get-ChildItem $env:VS_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName; `
|
||||
Enter-VsDevShell -VsInstallPath $env:VS_PATH -SkipAutomaticLocation -DevCmdArguments """-arch=$env:BUILD_ARCH"""; `
|
||||
`
|
||||
Write-Host 'Building Zlib library...'; `
|
||||
Set-Location -Path $env:BUILD_SRC\zlib; `
|
||||
(Get-Content .\win32\Makefile.msc).replace('-MD', '-MT') | Set-Content .\win32\Makefile.msc; `
|
||||
set CL=/MP; `
|
||||
nmake /S -f .\win32\Makefile.msc; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\zlib | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\zlib\include | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\zlib\lib | Out-Null; `
|
||||
Copy-Item $env:BUILD_SRC\zlib\*.h -Destination $env:BUILD_OUTPUT\zlib\include; `
|
||||
Copy-Item $env:BUILD_SRC\zlib\zlib.lib -Destination $env:BUILD_OUTPUT\zlib\lib; `
|
||||
Copy-Item $env:BUILD_SRC\zlib\zlib.pdb -Destination $env:BUILD_OUTPUT\zlib\lib; `
|
||||
nmake /S -f .\win32\Makefile.msc clean | Out-Null; `
|
||||
Write-Host 'Zlib is ready...'; `
|
||||
`
|
||||
Write-Host 'Building OpenSSL library...'; `
|
||||
Set-Location -Path $env:BUILD_SRC\openssl; `
|
||||
perl $env:BUILD_SRC\openssl\Configure `
|
||||
VC-WIN64A `
|
||||
no-shared `
|
||||
no-ui-console `
|
||||
no-tests `
|
||||
no-unit-test `
|
||||
no-capieng `
|
||||
--api=1.1.0 `
|
||||
--prefix=$env:BUILD_OUTPUT\openssl `
|
||||
--openssldir=$env:BUILD_OUTPUT\openssl_ssl; `
|
||||
set CL=/MP; `
|
||||
nmake /S build_sw; `
|
||||
nmake /S install_dev; `
|
||||
nmake /S clean | Out-Null; `
|
||||
Write-Host 'OpenSSL is ready...'; `
|
||||
`
|
||||
Write-Host 'Building PCRE library ...'; `
|
||||
Set-Location -Path $env:BUILD_SRC\pcre\build; `
|
||||
cmake --log-level=ERROR `
|
||||
-G 'Visual Studio 16 2019' `
|
||||
-A $env:BUILD_ARCH `
|
||||
-G 'Visual Studio 17 2022' `
|
||||
-A $env:BUILD_ARCH `
|
||||
-DPCRE_SUPPORT_UNICODE_PROPERTIES=ON `
|
||||
-DPCRE_SUPPORT_UTF=ON `
|
||||
-DCMAKE_C_FLAGS_RELEASE:string="""/MT""" ..; `
|
||||
@@ -175,42 +264,38 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
/target:pcre; `
|
||||
`
|
||||
Write-Host 'PCRE is ready...';
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\pcre | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\pcre\include | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\pcre\lib | Out-Null; `
|
||||
Copy-Item $env:BUILD_SRC\pcre\build\*.h -Destination $env:BUILD_OUTPUT\pcre\include; `
|
||||
Copy-Item $env:BUILD_SRC\pcre\build\Release\* -Destination $env:BUILD_OUTPUT\pcre\lib; `
|
||||
Remove-Item -Path $env:BUILD_SRC\pcre\build\* -Force -Recurse; `
|
||||
Write-Host 'PCRE is ready...'; `
|
||||
`
|
||||
Import-Module ('{0}\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -f ${env:ProgramFiles(x86)} ); `
|
||||
Enter-VsDevShell -VsInstallPath ('{0}\Microsoft Visual Studio\2019\BuildTools' -f ${env:ProgramFiles(x86)}) -DevCmdArguments """-arch=$env:BUILD_ARCH"""; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\openssl.tar.gz -Uri $env:OPENSSL_URL; `
|
||||
`
|
||||
$sha256 = 'c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\openssl.tar.gz -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum OpenSSL library failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Extracting archive ...'; `
|
||||
tar -zxf $env:SystemDrive\openssl.tar.gz; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\openssl.tar.gz; `
|
||||
Rename-Item -Path $env:SystemDrive\openssl-$env:OPENSSL_VERSION -NewName $env:SystemDrive\openssl_build; `
|
||||
`
|
||||
Write-Host 'Building OpenSSL library...'; `
|
||||
Set-Location -Path $env:SystemDrive\openssl_build; `
|
||||
perl $env:SystemDrive\openssl_build\Configure `
|
||||
VC-WIN64A `
|
||||
no-shared `
|
||||
no-ui-console `
|
||||
no-tests `
|
||||
# enable-capieng `
|
||||
no-capieng `
|
||||
--api=1.1.0 `
|
||||
--prefix=$env:SystemDrive\openssl_output `
|
||||
--openssldir=$env:SystemDrive\openssl_output_ssl; `
|
||||
Write-Host 'Building Curl library...'; `
|
||||
Set-Location -Path $env:BUILD_SRC\curl\winbuild; `
|
||||
(Get-Content MakefileBuild.vc).replace(' wldap32.lib', '') | Set-Content MakefileBuild.vc; `
|
||||
set CL=/MP; `
|
||||
nmake /S; `
|
||||
nmake /S install_sw; `
|
||||
Write-Host 'OpenSSL is ready...';
|
||||
nmake /S -f Makefile.vc `
|
||||
mode=static `
|
||||
VC=17 `
|
||||
DEBUG=no `
|
||||
CC="""cl.exe /DCURL_DISABLE_LDAP /DCURL_DISABLE_LDAPS""" `
|
||||
MACHINE=$env:BUILD_ARCH `
|
||||
USE_IPV6=yes `
|
||||
ENABLE_UNICODE=yes `
|
||||
USE_IDN=no `
|
||||
GEN_PDB=no `
|
||||
WITH_SSL=static `
|
||||
SSL_PATH=$env:BUILD_OUTPUT\openssl `
|
||||
WITH_ZLIB=static `
|
||||
ZLIB_PATH=$env:BUILD_OUTPUT\zlib `
|
||||
RTLIBCFG=static; `
|
||||
`
|
||||
Move-Item -Path $env:BUILD_SRC\curl\builds\libcurl-vc17-$env:BUILD_ARCH-release-static-ssl-static-zlib-static-sspi\ -Destination $env:BUILD_OUTPUT\curl; `
|
||||
Remove-Item -Path $env:BUILD_SRC\curl\builds\* -Force -Recurse; `
|
||||
Write-Host 'Curl is ready...'; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Recurse $env:TEMP\*;
|
||||
|
@@ -6,32 +6,38 @@ FROM $BUILD_BASE_IMAGE as builder_base
|
||||
ARG PCRE_VERSION=8.45
|
||||
ARG OPENSSL_VERSION=1.1.1s
|
||||
ARG GOLANG_VERSION=1.18.8
|
||||
ARG SEVEN_ZIP_VERSION=2107
|
||||
ARG SEVEN_ZIP_VERSION=2405
|
||||
|
||||
ARG MSYSTEM=UCRT64
|
||||
|
||||
ARG BUILD_ARCH=x64
|
||||
ARG CPU_MODEL=AMD64
|
||||
|
||||
ARG MAJOR_VERSION=5.0
|
||||
ARG ZBX_VERSION=${MAJOR_VERSION}.42
|
||||
|
||||
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/16/release/vs_buildtools.exe
|
||||
ARG GIT_URL=https://github.com/git-for-windows/git/releases/download/v2.33.0.windows.2/MinGit-2.33.0.2-busybox-64-bit.zip
|
||||
ARG MINGW_URL=https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.7z
|
||||
ARG GOLANG_URL=https://golang.org/dl/go$GOLANG_VERSION.windows-amd64.msi
|
||||
ARG CYGWIN_URL=https://cygwin.com/setup-x86_64.exe
|
||||
ARG SEVEN_ZIP_URL=https://www.7-zip.org/a/7z$SEVEN_ZIP_VERSION-$BUILD_ARCH.msi
|
||||
|
||||
ARG MINGW_URL=https://github.com/niXman/mingw-builds-binaries/releases/download/13.2.0-rt_v11-rev1/x86_64-13.2.0-release-win32-seh-ucrt-rt_v11-rev1.7z
|
||||
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/17/release/vs_buildtools.exe
|
||||
ARG GOLANG_URL=https://go.dev/dl/go$GOLANG_VERSION.windows-amd64.zip
|
||||
ARG MSYS2_URL=https://api.github.com/repos/msys2/msys2-installer/releases/latest
|
||||
|
||||
ARG PCRE_URL=https://sourceforge.net/projects/pcre/files/pcre/$PCRE_VERSION/pcre-$PCRE_VERSION.zip
|
||||
ARG OPENSSL_URL=https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
|
||||
ARG SEVEN_ZIP_URL=https://www.7-zip.org/a/7z$SEVEN_ZIP_VERSION-$BUILD_ARCH.msi
|
||||
|
||||
ENV ZBX_VERSION=$ZBX_VERSION `
|
||||
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
|
||||
GIT_URL=$GIT_URL SEVEN_ZIP_VERSION=$SEVEN_ZIP_VERSION `
|
||||
MINGW_URL=$MINGW_URL VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL GOLANG_VERSION=$GOLANG_VERSION MSYS2_URL=$MSYS2_URL `
|
||||
PCRE_VERSION=$PCRE_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
|
||||
GOLANG_VERSION=$GOLANG_VERSION SEVEN_ZIP_VERSION=$SEVEN_ZIP_VERSION `
|
||||
GIT_URL=$GIT_URL MINGW_URL=$MINGW_URL CYGWIN_URL=$CYGWIN_URL GOLANG_URL=$GOLANG_URL SEVEN_ZIP_URL=$SEVEN_ZIP_URL `
|
||||
PCRE_URL=$PCRE_URL OPENSSL_URL=$OPENSSL_URL
|
||||
PCRE_URL=$PCRE_URL OPENSSL_URL=$OPENSSL_URL `
|
||||
CHERE_INVOKING=yes MSYSTEM=$MSYSTEM
|
||||
|
||||
LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
|
||||
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
||||
org.opencontainers.image.vendor="Zabbix LLC" `
|
||||
org.opencontainers.image.vendor="Zabbix SIA" `
|
||||
org.opencontainers.image.url="https://zabbix.com/" `
|
||||
org.opencontainers.image.description="Zabbix build base image contains all required packages to build Zabbix agent 2 images" `
|
||||
org.opencontainers.image.licenses="GPL v2.0" `
|
||||
@@ -41,211 +47,232 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
`
|
||||
$env:PATH = [string]::Format('{0}\mingw64\bin;{0}\go\bin;{0}\git\cmd;{0}\git\mingw64\bin;{0}\git\usr\bin;{1}\7-Zip;', $env:SystemDrive, ${env:ProgramFiles}) + $env:PATH; `
|
||||
$env:PATH = $env:PATH + [string]::Format(';{0}\msys64\usr\bin;{0}\msys64\{1}\bin', $env:SystemDrive, $env:MSYSTEM.ToLower()); `
|
||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
$env:BUILD_OUTPUT = [string]::Format('{0}\build_output', $env:SystemDrive); `
|
||||
[Environment]::SetEnvironmentVariable('BUILD_OUTPUT', $env:BUILD_OUTPUT, [EnvironmentVariableTarget]::Machine); `
|
||||
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
|
||||
[Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:GIT_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\git.zip -Uri $env:GIT_URL; `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\git.zip -Uri $env:GIT_URL; `
|
||||
`
|
||||
$sha256 = '273f55e881094d00877d64f56570b0c997c4da5dedcb26738d56481033c1eba1'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\git.zip -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\git.zip -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum GIT for Windows failed!'; `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum GIT for Windows ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Installing ...'; `
|
||||
Expand-Archive -Path git.zip -DestinationPath $env:SystemDrive\git\.; `
|
||||
Write-Host ('Downloading {0} ...' -f $env:SEVEN_ZIP_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\7z.msi -Uri $env:SEVEN_ZIP_URL; `
|
||||
`
|
||||
$sha256 = '0F6AA6596D418B1694F62C8583DE05D24589B8D7FFACCE5A7DAB52AE71F832B6'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\7z.msi -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum 7-zip ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
|
||||
`
|
||||
$sha256 = '980788761e75ed33ffc4f2a7a3ff07cd90949bd023eb1a8d855ef0b5de9cbcba'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum Go Lang ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\mingw.7z -Uri $env:MINGW_URL; `
|
||||
`
|
||||
$sha256 = '74ca64c55220edd3196681782fbff653c2b9cb4f427f9e532ab6e9a0823dc997'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\mingw.7z -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum Mingw-w64 ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:MSYS2_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $(Invoke-RestMethod -UseBasicParsing $env:MSYS2_URL | `
|
||||
Select -ExpandProperty "assets" | `
|
||||
Select -ExpandProperty "browser_download_url" | `
|
||||
Select-String -Pattern '.sfx.exe$').ToString(); `
|
||||
`
|
||||
$sha256 = 'D96C53ECBFA4B9D81F6C58077965BB2E31472A8BDA4D4446EF8F45F9C601B11D'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum MSYS2 ({0}) failed!' -f $d_sha256); `
|
||||
# exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; `
|
||||
`
|
||||
Write-Host 'Installing GIT...'; `
|
||||
Expand-Archive `
|
||||
-Path $env:TEMP\git.zip `
|
||||
-DestinationPath $env:SystemDrive\git\.; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\git.zip; `
|
||||
$env:PATH = [string]::Format('{0}\git\cmd;{0}\git\mingw64\bin;{0}\git\usr\bin;', $env:SystemDrive) + $env:PATH; `
|
||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
Write-Host 'Verifying install ("git version") ...'; `
|
||||
git version; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\go-amd64.msi -Uri $env:GOLANG_URL; `
|
||||
$sha256 = '6d38668862bf9772c0c1c1e0f26aa5dedea9825b33f763b81ccc4aa63df2cef9'; `
|
||||
`
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\go-amd64.msi -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum Go Lang failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
Write-Host 'Installing ...'; `
|
||||
Write-Host 'Installing 7z...'; `
|
||||
Start-Process `
|
||||
-FilePath $env:SystemDrive\go-amd64.msi `
|
||||
-FilePath $env:TEMP\7z.msi `
|
||||
-Wait `
|
||||
-ArgumentList '/qn /norestart'; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\go-amd64.msi; `
|
||||
`
|
||||
$env:PATH = [string]::Format('{0}\Go\bin;', ${env:ProgramFiles}) + $env:PATH; `
|
||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
Write-Host 'Verifying install ("go version") ...'; `
|
||||
go version; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:SEVEN_ZIP_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\7z.msi -Uri $env:SEVEN_ZIP_URL; `
|
||||
`
|
||||
$sha256 = '5447C9AC39C48F1BC7C88359B0520396A8C9707B307C107236A93A68E6FD3EB6'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\7z.msi -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum 7-zip failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Installing ...'; `
|
||||
Start-Process `
|
||||
-FilePath $env:SystemDrive\7z.msi `
|
||||
-Wait `
|
||||
-ArgumentList '/qn /norestart'; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\7z.msi; `
|
||||
$env:PATH = [string]::Format('{0}\7-Zip;', ${env:ProgramFiles}) + $env:PATH; `
|
||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
Write-Host 'Verifying install ("7z -h") ...'; `
|
||||
7z -h | Select -first 2; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
(new-object System.Net.WebClient).DownloadFile("""$env:MINGW_URL""","""$env:SystemDrive\mingw.7z"""); `
|
||||
Write-Host 'Installing Go Lang...'; `
|
||||
Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; `
|
||||
`
|
||||
$sha256 = 'e8c65ddc655534b0330f66f7b480565621e8617cda9937d76ba141a22bf3b2fa'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\mingw.7z -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum Mingw-w64 failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
Write-Host 'Verifying install ("go version") ...'; `
|
||||
go version; `
|
||||
`
|
||||
Write-Host 'Installing ...'; `
|
||||
7z x $env:SystemDrive\mingw.7z; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\mingw.7z; `
|
||||
$env:PATH = [string]::Format('{0}\mingw64\bin;', $env:SystemDrive) + $env:PATH; `
|
||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
Write-Host 'Installing Mingw-w64...'; `
|
||||
7z x $env:TEMP\mingw.7z; `
|
||||
compact /c /i /s:$env:SystemDrive\mingw64 | Out-Null; `
|
||||
`
|
||||
Write-Host 'Verifying install ("mingw32-make -v") ...'; `
|
||||
mingw32-make -v; `
|
||||
Write-Host 'Verifying install ("gcc -v") ...'; `
|
||||
gcc -v; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; `
|
||||
Write-Host 'Installing MSYS2...'; `
|
||||
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
|
||||
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
|
||||
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
|
||||
bash -lc 'pacman --noprogressbar --sync --quiet --noconfirm mingw-w64-ucrt-x86_64-cmake'; `
|
||||
bash -lc 'pacman --noprogressbar --noconfirm -Scc'; `
|
||||
bash -lc 'rm -rf /usr/share/man/* /usr/share/doc/* /usr/share/locale/*'; `
|
||||
bash -lc 'rm -rf /$MSYSTEM/usr/share/man/* /$MSYSTEM/usr/share/doc/* /$MSYSTEM/usr/share/locale/*'; `
|
||||
bash -lc 'rm -rf /$MSYSTEM/share/man/* /$MSYSTEM/share/doc/* /$MSYSTEM/share/locale/*'; `
|
||||
bash -lc 'rm -rf /var/cache/pacman/pkg/*'; `
|
||||
taskkill /F /FI 'MODULES eq msys-2.0.dll' | Out-Null; `
|
||||
compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; `
|
||||
`
|
||||
Write-Host 'Verifying install ("bash --version") ...'; `
|
||||
bash --version; `
|
||||
`
|
||||
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
|
||||
cmd /C start /w $env:SystemDrive\vs_buildtools.exe `
|
||||
cmd /C start /w $env:TEMP\vs_buildtools.exe `
|
||||
--quiet `
|
||||
--wait `
|
||||
--norestart `
|
||||
--nocache `
|
||||
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\BuildTools""" `
|
||||
--channelUri https://aka.ms/vs/16/release/channel `
|
||||
--installChannelUri https://aka.ms/vs/16/release/channel `
|
||||
--channelId VisualStudio.16.Release `
|
||||
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019
|
||||
--add Microsoft.VisualStudio.Component.VC.CMake.Project; `
|
||||
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" `
|
||||
--channelUri https://aka.ms/vs/17/release/channel `
|
||||
--installChannelUri https://aka.ms/vs/17/release/channel `
|
||||
--channelId VisualStudio.17.Release `
|
||||
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
|
||||
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64; `
|
||||
if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { `
|
||||
throw $err; `
|
||||
}; `
|
||||
Wait-Process -name msiexec; `
|
||||
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
|
||||
`
|
||||
Write-Host 'Visual Studio components installation cleanup'; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\vs_buildtools.exe; `
|
||||
Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; `
|
||||
Remove-Item -Force -Recurse $env:TEMP\*; `
|
||||
Write-Host 'Build environment is ready...';
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
$env:VS_PATH = &(Join-Path ${env:ProgramFiles(x86)} """\Microsoft Visual Studio\Installer\vswhere.exe""") -latest -products Microsoft.VisualStudio.Product.BuildTools -property installationPath; `
|
||||
[Environment]::SetEnvironmentVariable('VS_PATH', $env:VS_PATH, [EnvironmentVariableTarget]::Machine); `
|
||||
`
|
||||
Import-Module ('{0}\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -f ${env:ProgramFiles(x86)} ); `
|
||||
Enter-VsDevShell -VsInstallPath ('{0}\Microsoft Visual Studio\2019\BuildTools' -f ${env:ProgramFiles(x86)}) -DevCmdArguments """-arch=$env:BUILD_ARCH"""; `
|
||||
Write-Host 'Visual Studio components installation cleanup'; `
|
||||
Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Recurse $env:TEMP\*; `
|
||||
Write-Host 'Build environment is ready...'; `
|
||||
`
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
`
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; `
|
||||
Set-Location -Path $env:BUILD_SRC; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:PCRE_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
(new-object System.Net.WebClient).DownloadFile("""$env:PCRE_URL""","""$env:SystemDrive\pcre.zip"""); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\pcre.zip -Uri $env:PCRE_URL; `
|
||||
`
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
$sha256 = '5b709aa45ea3b8bb73052947200ad187f651a2049158fb5bbfed329e4322a977'; `
|
||||
if ((Get-FileHash $env:SystemDrive\pcre.zip -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum PCRE library failed!'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\pcre.zip -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum PCRE library ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
Write-Host 'Extracting archive ...'; `
|
||||
Expand-Archive -Path $env:SystemDrive\pcre.zip -DestinationPath $env:SystemDrive; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\pcre.zip; `
|
||||
Rename-Item -Path $env:SystemDrive\pcre-$env:PCRE_VERSION -NewName $env:SystemDrive\pcre_build; `
|
||||
`
|
||||
Set-Location -Path $env:SystemDrive\pcre_build; `
|
||||
Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); `
|
||||
Invoke-WebRequest -OutFile $env:TEMP\openssl.tar.gz -Uri $env:OPENSSL_URL; `
|
||||
`
|
||||
$sha256 = '6ae015467dabf0469b139ada93319327be24b98251ffaeceda0221848dc09262'; `
|
||||
$d_sha256 = (Get-FileHash $env:TEMP\openssl.tar.gz -Algorithm sha256).Hash; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ($d_sha256 -ne $sha256) { `
|
||||
Write-Host ('Checksum OpenSSL library ({0}) failed!' -f $d_sha256); `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Extracting PCRE archive ...'; `
|
||||
Expand-Archive -Path $env:TEMP\pcre.zip -DestinationPath $env:BUILD_SRC; `
|
||||
`
|
||||
Write-Host 'Removing downloaded ...'; `
|
||||
Remove-Item -Force -Path $env:TEMP\pcre.zip; `
|
||||
Rename-Item -Path $env:BUILD_SRC\pcre-$env:PCRE_VERSION -NewName $env:BUILD_SRC\pcre; `
|
||||
`
|
||||
Write-Host 'Extracting OpenSSL archive ...'; `
|
||||
$env:SystemDirectory = [Environment]::SystemDirectory; `
|
||||
tar -zxf "$env:TEMP\openssl.tar.gz"; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:TEMP\openssl.tar.gz; `
|
||||
Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; `
|
||||
`
|
||||
Write-Host 'Building PCRE library ...'; `
|
||||
Set-Location -Path $env:BUILD_SRC\pcre; `
|
||||
cmake --log-level=ERROR `
|
||||
-G 'MinGW Makefiles' `
|
||||
-DBUILD_SHARED_LIBS=OFF `
|
||||
-DBUILD_STATIC_LIBS=ON `
|
||||
-DPCRE_DEBUG=OFF `
|
||||
-DPCRE_BUILD_TESTS=OFF `
|
||||
-DINSTALL_MSVC_PDB=OFF `
|
||||
-DCMAKE_C_COMPILER=gcc `
|
||||
-DCMAKE_C_FLAGS='-O2 -g' `
|
||||
-DCMAKE_CXX_FLAGS='-O2 -g' `
|
||||
-DCMAKE_INSTALL_PREFIX="""$env:SystemDrive\pcre_output""" . ; `
|
||||
-DCMAKE_INSTALL_PREFIX="""$env:BUILD_OUTPUT\pcre""" . ; `
|
||||
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS"""; `
|
||||
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install; `
|
||||
Write-Host 'PCRE is ready...';
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:CYGWIN_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
(New-Object Net.WebClient).DownloadFile("""$env:CYGWIN_URL""", """$env:SystemDrive\setup.exe"""); `
|
||||
`
|
||||
$sha256 = '3d9e0143268f52aecaff76f81553c880ec9a353eb5a6e22bd6d34bad8251710c'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\setup.exe -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum Cygwin failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
Write-Host 'Installing ...'; `
|
||||
Start-Process $env:SystemDrive\setup.exe `
|
||||
-ArgumentList """-qnNdO -a x86_64 -R $env:SystemDrive\cygwin --site http://cygwin.mirror.constant.com -l $env:SystemDrive\cygwin\var\cache\setup --packages perl""" `
|
||||
-Wait `
|
||||
-NoNewWindow; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\setup.exe; `
|
||||
Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\openssl.tar.gz -Uri $env:OPENSSL_URL; `
|
||||
`
|
||||
$sha256 = 'c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\openssl.tar.gz -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum OpenSSL library failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Extracting archive ...'; `
|
||||
tar -zxf $env:SystemDrive\openssl.tar.gz; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\openssl.tar.gz; `
|
||||
Rename-Item -Path $env:SystemDrive\openssl-$env:OPENSSL_VERSION -NewName $env:SystemDrive\openssl_build; `
|
||||
mingw32-make -s clean | Out-Null; `
|
||||
Remove-Item -Path $env:BUILD_OUTPUT\pcre\man -Force -Recurse; `
|
||||
Remove-Item -Path $env:BUILD_OUTPUT\pcre\share -Force -Recurse; `
|
||||
Write-Host 'PCRE is ready...'; `
|
||||
`
|
||||
Write-Host 'Building OpenSSL library...'; `
|
||||
Set-Location -Path $env:SystemDrive\openssl_build; `
|
||||
$env:PATH+=""";$env:SystemDrive\cygwin\bin"""; `
|
||||
Set-Location -Path $env:BUILD_SRC\openssl; `
|
||||
perl Configure `
|
||||
mingw64 `
|
||||
no-shared `
|
||||
no-ui-console `
|
||||
no-tests `
|
||||
# enable-capieng `
|
||||
no-unit-test `
|
||||
no-capieng `
|
||||
--api=1.1.0 `
|
||||
--prefix=$env:SystemDrive\openssl_output `
|
||||
--openssldir=$env:SystemDrive\openssl_output_ssl; `
|
||||
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS"""; `
|
||||
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install_sw; `
|
||||
--libdir=lib `
|
||||
--prefix=$env:BUILD_OUTPUT/openssl `
|
||||
--openssldir=$env:BUILD_OUTPUT/openssl_ssl; `
|
||||
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" build_sw; `
|
||||
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install_dev; `
|
||||
mingw32-make -s clean | Out-Null; `
|
||||
Write-Host 'OpenSSL is ready...'; `
|
||||
Write-Host 'Removing cygwin...'; `
|
||||
Remove-Item -Recurse -Force -Path $env:SystemDrive\cygwin;
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Recurse $env:TEMP\*;
|
||||
|
Reference in New Issue
Block a user