mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2024-11-22 07:43:47 +01:00
Updated build process for Zabbix agent (windows)
This commit is contained in:
parent
c008da801f
commit
6d942a8554
@ -3,27 +3,32 @@
|
||||
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
|
||||
FROM $BUILD_BASE_IMAGE
|
||||
|
||||
ARG PCRE2_VERSION=10.42
|
||||
ARG OPENSSL_VERSION=3.1.4
|
||||
ARG LIBMODBUS_VERSION=v3.1.10
|
||||
ARG PCRE2_VERSION=10.43
|
||||
ARG OPENSSL_VERSION=3.3.0
|
||||
ARG LIBMODBUS_VERSION=3.1.10
|
||||
ARG ZLIB_VERSION=1.3.1
|
||||
ARG CURL_VERSION=8.7.1
|
||||
ARG BUILD_ARCH=x64
|
||||
ARG CPU_MODEL=AMD64
|
||||
|
||||
ARG MAJOR_VERSION=7.0
|
||||
ARG ZBX_VERSION=${MAJOR_VERSION}
|
||||
|
||||
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 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 PERL_URL=https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_53822_64bit/strawberry-perl-5.38.2.2-64bit-portable.zip
|
||||
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 PCRE2_URL=https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.zip
|
||||
ARG OPENSSL_URL=https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
|
||||
ARG LIBMODBUS_URL=https://github.com/stephane/libmodbus.git
|
||||
ARG LIBMODBUS_URL=https://github.com/stephane/libmodbus/archive/refs/tags/v$LIBMODBUS_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 `
|
||||
PCRE2_VERSION=$PCRE2_VERSION OPENSSL_VERSION=$OPENSSL_VERSION LIBMODBUS_VERSION=$LIBMODBUS_VERSION `
|
||||
GIT_URL=$GIT_URL NASM_URL=$NASM_URL PERL_URL=$PERL_URL LIBMODBUS_URL=$LIBMODBUS_URL PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL
|
||||
GIT_URL=$GIT_URL NASM_URL=$NASM_URL PERL_URL=$PERL_URL LIBMODBUS_URL=$LIBMODBUS_URL PCRE2_URL=$PCRE2_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>" `
|
||||
@ -37,7 +42,14 @@ LABEL org.opencontainers.image.title="Zabbix agent build base for Windows" `
|
||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
`
|
||||
$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; `
|
||||
@ -48,83 +60,72 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
Write-Host 'Checksum GIT for Windows failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Installing ...'; `
|
||||
Expand-Archive `
|
||||
-Path 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'; `
|
||||
`
|
||||
$sha256 = '657E1252676CFB26A008835C20A760F731C8E0414469A4ED0F83F0FB059CDD35'; `
|
||||
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 ('Downloading {0} ...' -f $env:PERL_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\perl.zip -Uri $env:PERL_URL; `
|
||||
`
|
||||
$sha256 = 'EA451686065D6338D7E4D4A04C9AF49F17951D15AA4C2E19AB8CB56FA2373440'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\perl.zip -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum Strawberry Perl failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
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 GIT...'; `
|
||||
Expand-Archive `
|
||||
-Path git.zip `
|
||||
-DestinationPath $env:SystemDrive\git\.; `
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\git.zip; `
|
||||
`
|
||||
Write-Host 'Verifying install ("git version") ...'; `
|
||||
git version; `
|
||||
Write-Host 'Installing NASM...'; `
|
||||
Start-Process `
|
||||
-FilePath $env:SystemDrive\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 'Installing Perl...'; `
|
||||
Expand-Archive -Path $env:SystemDrive\perl.zip -DestinationPath $env:SystemDrive\perl\; `
|
||||
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); `
|
||||
Remove-Item -Force -Path $env:SystemDrive\perl.zip; `
|
||||
`
|
||||
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 `
|
||||
--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; `
|
||||
@ -139,34 +140,149 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
Remove-Item -Force -Recurse $env:TEMP\*; `
|
||||
Write-Host 'Build environment is ready...';
|
||||
|
||||
COPY modbus.vs16.* C:\build_src\libmodbus_project\
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
`
|
||||
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:PCRE2_URL); `
|
||||
`
|
||||
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:PCRE2_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:SystemDrive\pcre2.zip -Uri $env:PCRE2_URL; `
|
||||
Invoke-WebRequest -OutFile $env:BUILD_SRC\pcre2.zip -Uri $env:PCRE2_URL; `
|
||||
`
|
||||
$sha256 = '0f2a1403733d1a409e9305996bf8e5ea7f69ed38f38d2bc1e0c0b041ad7a01a9'; `
|
||||
$sha256 = 'F2816E84DD7A402068797501BF69E24ECA18D882ADB2143DE9F831F39B850257'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:SystemDrive\pcre2.zip -Algorithm sha256).Hash -ne $sha256) { `
|
||||
if ((Get-FileHash $env:BUILD_SRC\pcre2.zip -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum PCRE2 library failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
Write-Host 'Extracting archive ...'; `
|
||||
Expand-Archive -Path $env:SystemDrive\pcre2.zip -DestinationPath $env:SystemDrive; `
|
||||
Expand-Archive -Path $env:BUILD_SRC\pcre2.zip -DestinationPath $env:BUILD_SRC; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:SystemDrive\pcre2.zip; `
|
||||
Rename-Item -Path $env:SystemDrive\pcre2-$env:PCRE2_VERSION -NewName $env:SystemDrive\pcre2_build; `
|
||||
New-Item -ItemType directory -Path "$env:SystemDrive\pcre2_build\build" | Out-Null; `
|
||||
Remove-Item -Force -Path $env:BUILD_SRC\pcre2.zip; `
|
||||
Rename-Item -Path $env:BUILD_SRC\pcre2-$env:PCRE2_VERSION -NewName $env:BUILD_SRC\pcre2; `
|
||||
New-Item -ItemType directory -Path "$env:BUILD_SRC\pcre2\build" | Out-Null; `
|
||||
`
|
||||
Set-Location -Path $env:SystemDrive\pcre2_build\build; `
|
||||
Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:BUILD_SRC\openssl.tar.gz -Uri $env:OPENSSL_URL; `
|
||||
`
|
||||
$sha256 = '53E66B043322A606ABF0087E7699A0E033A37FA13FEB9742DF35C3A33B18FB02'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:BUILD_SRC\openssl.tar.gz -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum OpenSSL library failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Extracting archive ...'; `
|
||||
tar -zxf $env:BUILD_SRC\openssl.tar.gz; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:BUILD_SRC\openssl.tar.gz; `
|
||||
Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:LIBMODBUS_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:BUILD_SRC\libmodbus.tar.gz -Uri $env:LIBMODBUS_URL; `
|
||||
`
|
||||
$sha256 = 'E93503749CD89FDA4C8CF1EE6371A3A9CC1F0A921C165AFBBC4FD96D4813FA1A'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:BUILD_SRC\libmodbus.tar.gz -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum Libmodbus library failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Extracting archive ...'; `
|
||||
tar -zxf $env:BUILD_SRC\libmodbus.tar.gz; `
|
||||
Move-Item -Path $env:BUILD_SRC\libmodbus-$env:LIBMODBUS_VERSION\ -Destination $env:BUILD_SRC\libmodbus; `
|
||||
Move-Item -Path $env:BUILD_SRC\libmodbus_project\* -Destination $env:BUILD_SRC\libmodbus\src\win32; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:BUILD_SRC\libmodbus.tar.gz; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:ZLIB_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:BUILD_SRC\zlib.tar.gz -Uri $env:ZLIB_URL; `
|
||||
`
|
||||
$sha256 = '9A93B2B7DFDAC77CEBA5A558A580E74667DD6FEDE4585B91EEFB60F03B72DF23'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:BUILD_SRC\zlib.tar.gz -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum Zlib library failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Extracting archive ...'; `
|
||||
tar -zxf $env:BUILD_SRC\zlib.tar.gz; `
|
||||
Move-Item -Path $env:BUILD_SRC\zlib-$env:ZLIB_VERSION\ -Destination $env:BUILD_SRC\zlib; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:BUILD_SRC\zlib.tar.gz; `
|
||||
`
|
||||
Write-Host ('Downloading {0} ...' -f $env:CURL_URL); `
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||
Invoke-WebRequest -OutFile $env:BUILD_SRC\curl.tar.gz -Uri $env:CURL_URL; `
|
||||
`
|
||||
$sha256 = 'F91249C87F68EA00CF27C44FDFA5A78423E41E71B7D408E5901A9896D905C495'; `
|
||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||
if ((Get-FileHash $env:BUILD_SRC\curl.tar.gz -Algorithm sha256).Hash -ne $sha256) { `
|
||||
Write-Host 'Checksum Curl library failed!'; `
|
||||
exit 1; `
|
||||
}; `
|
||||
`
|
||||
Write-Host 'Extracting archive ...'; `
|
||||
tar -zxf $env:BUILD_SRC\curl.tar.gz; `
|
||||
Move-Item -Path $env:BUILD_SRC\curl-$env:CURL_VERSION\ -Destination $env:BUILD_SRC\curl; `
|
||||
`
|
||||
Write-Host 'Removing downloaded...'; `
|
||||
Remove-Item -Force -Path $env:BUILD_SRC\curl.tar.gz; `
|
||||
Set-Location -Path $env:SystemDrive\.; `
|
||||
`
|
||||
Import-Module ('{0}\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -f ${env:ProgramFiles(x86)} ); `
|
||||
Enter-VsDevShell -VsInstallPath ('{0}\Microsoft Visual Studio\2022\BuildTools' -f ${env:ProgramFiles(x86)}) -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 `
|
||||
# enable-capieng `
|
||||
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 PCRE2 library ...'; `
|
||||
Set-Location -Path $env:BUILD_SRC\pcre2\build; `
|
||||
cmake --log-level=ERROR `
|
||||
-G 'Visual Studio 16 2019' `
|
||||
-A $env:BUILD_ARCH `
|
||||
-DBUILD_SHARED_LIBS=OFF `
|
||||
-G 'Visual Studio 17 2022' `
|
||||
-A $env:BUILD_ARCH `
|
||||
-DBUILD_SHARED_LIBS=OFF `
|
||||
-DPCRE2_BUILD_TESTS=OFF `
|
||||
-DCMAKE_C_FLAGS_RELEASE:string="""/MT""" ..; `
|
||||
msbuild PCRE2.sln `
|
||||
-maxcpucount:"""$env:NUMBER_OF_PROCESSORS""" `
|
||||
@ -175,68 +291,51 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
/property:Platform=$env:BUILD_ARCH `
|
||||
/target:pcre2-8-static; `
|
||||
`
|
||||
Write-Host 'PCRE2 is ready...';
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
`
|
||||
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 = '840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3'; `
|
||||
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; `
|
||||
set CL=/MP; `
|
||||
nmake /S build_sw; `
|
||||
nmake /S install_dev; `
|
||||
Write-Host 'OpenSSL is ready...';
|
||||
|
||||
COPY modbus.vs16.vcxproj c:\
|
||||
COPY modbus.vs16.sln c:\
|
||||
COPY modbus.vs16.vcxproj.filters c:\
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
`
|
||||
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 ('Checkout GIT {0} repository ...' -f $env:LIBMODBUS_URL); `
|
||||
git -c advice.detachedHead=false clone $env:LIBMODBUS_URL --branch $env:LIBMODBUS_VERSION --depth 1 --single-branch $env:SystemDrive\libmodbus; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\pcre2 | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\pcre2\include | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\pcre2\lib | Out-Null; `
|
||||
Copy-Item $env:BUILD_SRC\pcre2\build\*.h -Destination $env:BUILD_OUTPUT\pcre2\include; `
|
||||
Copy-Item $env:BUILD_SRC\pcre2\build\Release\* -Destination $env:BUILD_OUTPUT\pcre2\lib; `
|
||||
Remove-Item -Path $env:BUILD_SRC\pcre2\build\* -Force -Recurse; `
|
||||
Write-Host 'PCRE2 is ready...'; `
|
||||
`
|
||||
Write-Host 'Building Libmodbus library...'; `
|
||||
Copy-Item -Path $env:SystemDrive\modbus.vs16.vcxproj $env:SystemDrive\libmodbus\src\win32\modbus.vs16.vcxproj; `
|
||||
Copy-Item -Path $env:SystemDrive\modbus.vs16.sln $env:SystemDrive\libmodbus\src\win32\modbus.vs16.sln; `
|
||||
Copy-Item -Path $env:SystemDrive\modbus.vs16.vcxproj.filters $env:SystemDrive\libmodbus\src\win32\modbus.vs16.vcxproj.filters; `
|
||||
Set-Location -Path $env:SystemDrive\libmodbus\src\win32; `
|
||||
`
|
||||
Set-Location -Path $env:BUILD_SRC\libmodbus\src\win32; `
|
||||
cscript .\configure.js; `
|
||||
msbuild modbus.vs16.sln `
|
||||
-maxcpucount:"""$env:NUMBER_OF_PROCESSORS""" `
|
||||
/verbosity:quiet `
|
||||
/property:Configuration=Release `
|
||||
/property:Platform=$env:BUILD_ARCH; `
|
||||
Write-Host 'Libmodbus is ready...';
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\libmodbus | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\libmodbus\include | Out-Null; `
|
||||
New-Item -ItemType directory -Path $env:BUILD_OUTPUT\libmodbus\lib | Out-Null; `
|
||||
Copy-Item $env:BUILD_SRC\libmodbus\src\*.h -Destination $env:BUILD_OUTPUT\libmodbus\include; `
|
||||
Copy-Item $env:BUILD_SRC\libmodbus\src\win32\$env:BUILD_ARCH\Release\*.lib -Destination $env:BUILD_OUTPUT\libmodbus\lib; `
|
||||
Copy-Item $env:BUILD_SRC\libmodbus\src\win32\$env:BUILD_ARCH\Release\*.pdb -Destination $env:BUILD_OUTPUT\libmodbus\lib; `
|
||||
Remove-Item -Path $env:BUILD_SRC\libmodbus\src\win32\$env:BUILD_ARCH -Force -Recurse; `
|
||||
Write-Host 'Libmodbus is ready...'; `
|
||||
`
|
||||
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 -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...';
|
||||
|
@ -28,24 +28,24 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
|
@ -11,7 +11,9 @@ ARG ZBX_VERSION
|
||||
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
||||
ARG GIT_BRANCH=master
|
||||
ARG ZABBIX_VERSION_RC_NUM=2400
|
||||
ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION ZBX_VERSION=$ZBX_VERSION ZABBIX_VERSION_RC_NUM=$ZABBIX_VERSION_RC_NUM
|
||||
|
||||
ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION ZBX_VERSION=$ZBX_VERSION GIT_BRANCH=${GIT_BRANCH:-$ZBX_VERSION} `
|
||||
ZABBIX_VERSION_RC_NUM=$ZABBIX_VERSION_RC_NUM
|
||||
|
||||
LABEL org.opencontainers.image.title="Zabbix agent build (Windows)" `
|
||||
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
||||
@ -27,13 +29,11 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPref
|
||||
|
||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
`
|
||||
$GIT_BRANCH = if ( $env:GIT_BRANCH ) { $env:GIT_BRANCH } else { $env:ZBX_VERSION }; `
|
||||
Import-Module ('{0}\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll' -f ${env:ProgramFiles(x86)} ); `
|
||||
Enter-VsDevShell -VsInstallPath ('{0}\Microsoft Visual Studio\2022\BuildTools' -f ${env:ProgramFiles(x86)}) -DevCmdArguments """-arch=$env:BUILD_ARCH"""; `
|
||||
`
|
||||
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 ('Checkout GIT {0} ({1}) repository ...' -f $env:ZBX_SOURCES, $GIT_BRANCH); `
|
||||
git -c advice.detachedHead=false clone $env:ZBX_SOURCES --branch $GIT_BRANCH --depth 1 --single-branch $env:SystemDrive\zabbix-$env:ZBX_VERSION; `
|
||||
Write-Host ('Checkout GIT {0} ({1}) repository ...' -f $env:ZBX_SOURCES, $env:GIT_BRANCH); `
|
||||
git -c advice.detachedHead=false clone $env:ZBX_SOURCES --branch $env:GIT_BRANCH --depth 1 --single-branch $env:SystemDrive\zabbix-$env:ZBX_VERSION; `
|
||||
`
|
||||
Write-Host ('Building Zabbix {0} version ...' -f $env:ZBX_VERSION); `
|
||||
Set-Location -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION; `
|
||||
@ -43,15 +43,15 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
||||
set CL=/MP; `
|
||||
nmake /S -f Makefile `
|
||||
CPU=$env:CPU_MODEL `
|
||||
CFLAGS="""/D ZABBIX_VERSION_REVISION=$ZbxRevision /D HAVE_LIBMODBUS_STATIC""" `
|
||||
PCRE2INCDIR=$env:SystemDrive\pcre2_build\build `
|
||||
PCRE2LIBDIR=$env:SystemDrive\pcre2_build\build\Release TLS=openssl `
|
||||
CFLAGS="""/D CURL_STATICLIB /D HAVE_LIBCURL /I "$env:BUILD_OUTPUT\curl\include" /D ZABBIX_VERSION_REVISION=$ZbxRevision /D HAVE_LIBMODBUS_STATIC /D DEFAULT_CONFIG_FILE=$env:SystemDrive\zabbix\conf\zabbix_agentd.win.conf""" `
|
||||
PCRE2INCDIR=$env:SystemDrive\build_output\pcre2\include `
|
||||
PCRE2LIBDIR=$env:SystemDrive\build_output\pcre2\lib TLS=openssl `
|
||||
RFLAGS="""/D ZABBIX_VERSION_REVISION=$ZbxRevision /D ZABBIX_VERSION_RC_NUM=$env:ZABBIX_VERSION_RC_NUM""" `
|
||||
# LIBS="Crypt32.lib" `
|
||||
TLSINCDIR=$env:SystemDrive\openssl_output\include `
|
||||
TLSLIBDIR=$env:SystemDrive\openssl_output\lib `
|
||||
MODBINCDIR=$env:SystemDrive\libmodbus\src `
|
||||
MODBLIBDIR=$env:SystemDrive\libmodbus\src\win32\$env:BUILD_ARCH\Release `
|
||||
TLSINCDIR=$env:BUILD_OUTPUT\openssl\include `
|
||||
TLSLIBDIR=$env:BUILD_OUTPUT\openssl\lib `
|
||||
MODBINCDIR=$env:BUILD_OUTPUT\libmodbus\include `
|
||||
MODBLIBDIR=$env:BUILD_OUTPUT\libmodbus\lib `
|
||||
LIBS="""$env:LIBS Crypt32.lib $env:BUILD_OUTPUT\curl\lib\libcurl_a.lib $env:BUILD_OUTPUT\zlib\lib\zlib.lib""" `
|
||||
all; `
|
||||
`
|
||||
Write-Host 'Verifying build ("zabbix_agentd.exe -V") ...'; `
|
||||
|
Loading…
Reference in New Issue
Block a user