diff --git a/Dockerfiles/agent/windows/Dockerfile b/Dockerfiles/agent/windows/Dockerfile index 45c19348e..10e53c0fe 100644 --- a/Dockerfiles/agent/windows/Dockerfile +++ b/Dockerfiles/agent/windows/Dockerfile @@ -38,16 +38,16 @@ RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemD ` $env:ZBX_HOME = [string]::Format('{0}\zabbix', $env:SystemDrive); ` [Environment]::SetEnvironmentVariable('ZBX_HOME', $env:ZBX_HOME, [EnvironmentVariableTarget]::Machine); ` - ` - Write-Host ('Verifying Zabbix agent 2 {0} ...' -f $env:ZBX_VERSION); ` - zabbix_agentd.exe -V; + ` + Write-Host ('Verifying Zabbix agent 2 {0} ...' -f $env:ZBX_VERSION); ` + zabbix_agentd.exe -V; RUN Set-Location -Path $env:SystemDrive\.; ` ` - New-Item -ItemType directory -Path $env:ZBX_HOME\conf\zabbix_agentd.d | Out-Null; ` - New-Item -ItemType directory -Path $env:ZBX_HOME\enc | Out-Null; ` - New-Item -ItemType directory -Path $env:ZBX_HOME\modules | Out-Null; ` - New-Item -ItemType directory -Path $env:ZBX_HOME\buffer | Out-Null; ` + New-Item -Force -ItemType directory -Path $env:ZBX_HOME\conf\zabbix_agentd.d | Out-Null; ` + New-Item -Force -ItemType directory -Path $env:ZBX_HOME\enc | Out-Null; ` + New-Item -Force -ItemType directory -Path $env:ZBX_HOME\modules | Out-Null; ` + New-Item -Force -ItemType directory -Path $env:ZBX_HOME\buffer | Out-Null; ` ` net accounts /MaxPWAge:unlimited; ` net user /add zabbix /expire:never /passwordreq:no; ` @@ -60,4 +60,4 @@ USER zabbix EXPOSE 10050/TCP -CMD C:\zabbix\docker-entrypoint.ps1 C:\zabbix\sbin\zabbix_agentd.exe -c C:\zabbix\conf\zabbix_agentd.win.conf -f +CMD C:\zabbix\docker-entrypoint.ps1 C:\zabbix\sbin\zabbix_agentd.exe -c C:\zabbix\conf\zabbix_agentd.conf -f diff --git a/Dockerfiles/build-base/windows/Dockerfile.agent b/Dockerfiles/build-base/windows/Dockerfile.agent index dd7c5b82a..daee37fd6 100644 --- a/Dockerfiles/build-base/windows/Dockerfile.agent +++ b/Dockerfiles/build-base/windows/Dockerfile.agent @@ -14,10 +14,12 @@ ARG CPU_MODEL=AMD64 ARG MAJOR_VERSION=7.0 ARG ZBX_VERSION=${MAJOR_VERSION} +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 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/archive/refs/tags/v$LIBMODBUS_VERSION.tar.gz @@ -26,9 +28,11 @@ 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 ` 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 ` - ZLIB_URL=$ZLIB_URL CURL_URL=$CURL_URL + PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL LIBMODBUS_URL=$LIBMODBUS_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 " ` @@ -53,24 +57,26 @@ RUN Set-Location -Path $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); ` 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:TEMP\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 ('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 failed!'; ` + Write-Host ('Checksum NASM ({0}) failed!' -f $d_sha256); ` exit 1; ` }; ` ` @@ -78,9 +84,10 @@ RUN Set-Location -Path $env:SystemDrive\.; ` 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 ((Get-FileHash $env:TEMP\perl.zip -Algorithm sha256).Hash -ne $sha256) { ` - Write-Host 'Checksum Strawberry Perl failed!'; ` + if ($d_sha256 -ne $sha256) { ` + Write-Host ('Checksum Strawberry Perl ({0}) failed!' -f $d_sha256); ` exit 1; ` }; ` ` @@ -101,13 +108,13 @@ RUN Set-Location -Path $env:SystemDrive\.; ` ` Write-Host 'Verifying install ("nasm -v") ...'; ` nasm -v; ` - ` + ` Write-Host 'Installing Perl...'; ` Expand-Archive -Path $env:TEMP\perl.zip -DestinationPath $env:SystemDrive\perl\; ` ` Write-Host 'Verifying install ("perl -V") ...'; ` perl -V; ` - ` + ` Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); ` cmd /C start /w $env:TEMP\vs_buildtools.exe ` --quiet ` @@ -132,108 +139,112 @@ RUN Set-Location -Path $env:SystemDrive\.; ` ` 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:PCRE2_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\pcre2.zip -Uri $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); ` + Invoke-WebRequest -OutFile $env:TEMP\pcre2.zip -Uri $env:PCRE2_URL; ` ` $sha256 = 'F2816E84DD7A402068797501BF69E24ECA18D882ADB2143DE9F831F39B850257'; ` + $d_sha256 = (Get-FileHash $env:TEMP\pcre2.zip -Algorithm sha256).Hash; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:TEMP\pcre2.zip -Algorithm sha256).Hash -ne $sha256) { ` - Write-Host 'Checksum PCRE2 library failed!'; ` + if ($d_sha256 -ne $sha256) { ` + Write-Host ('Checksum PCRE2 library ({0}) failed!' -f $d_sha256); ` exit 1; ` }; ` - Write-Host 'Extracting archive ...'; ` - Expand-Archive -Path $env:TEMP\pcre2.zip -DestinationPath $env:BUILD_SRC; ` - ` - Write-Host 'Removing downloaded...'; ` - 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; ` ` Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); ` Invoke-WebRequest -OutFile $env:TEMP\openssl.tar.gz -Uri $env:OPENSSL_URL; ` ` $sha256 = '53E66B043322A606ABF0087E7699A0E033A37FA13FEB9742DF35C3A33B18FB02'; ` + $d_sha256 = (Get-FileHash $env:TEMP\openssl.tar.gz -Algorithm sha256).Hash; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:TEMP\openssl.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` - Write-Host 'Checksum OpenSSL library failed!'; ` + if ($d_sha256 -ne $sha256) { ` + Write-Host ('Checksum OpenSSL library ({0}) failed!' -f $d_sha256); ` exit 1; ` }; ` ` - Write-Host 'Extracting archive ...'; ` - tar -zxf $env:TEMP\openssl.tar.gz; ` - ` - Write-Host 'Removing downloaded...'; ` - Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; ` - ` Write-Host ('Downloading {0} ...' -f $env:LIBMODBUS_URL); ` Invoke-WebRequest -OutFile $env:TEMP\libmodbus.tar.gz -Uri $env:LIBMODBUS_URL; ` ` $sha256 = 'E93503749CD89FDA4C8CF1EE6371A3A9CC1F0A921C165AFBBC4FD96D4813FA1A'; ` + $d_sha256 = (Get-FileHash $env:TEMP\libmodbus.tar.gz -Algorithm sha256).Hash; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ((Get-FileHash $env:TEMP\libmodbus.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` - Write-Host 'Checksum Libmodbus library failed!'; ` + if ($d_sha256 -ne $sha256) { ` + Write-Host ('Checksum Libmodbus library ({0}) failed!' -f $d_sha256); ` exit 1; ` }; ` ` - Write-Host 'Extracting archive ...'; ` - tar -zxf $env:TEMP\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 ('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 ((Get-FileHash $env:TEMP\zlib.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` - Write-Host 'Checksum Zlib library failed!'; ` + if ($d_sha256 -ne $sha256) { ` + Write-Host ('Checksum Zlib library ({0}) failed!' -f $d_sha256); ` exit 1; ` }; ` ` - Write-Host 'Extracting 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 ('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 ((Get-FileHash $env:TEMP\curl.tar.gz -Algorithm sha256).Hash -ne $sha256) { ` - Write-Host 'Checksum Curl library failed!'; ` + if ($d_sha256 -ne $sha256) { ` + Write-Host ('Checksum Curl library ({0}) failed!' -f $d_sha256); ` exit 1; ` }; ` ` - Write-Host 'Extracting 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\.; ` + Write-Host 'Extracting PCRE2 archive ...'; ` + Expand-Archive -Path $env:TEMP\pcre2.zip -DestinationPath $env:BUILD_SRC; ` + 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; ` ` - Import-Module (Get-ChildItem $env:VS_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName; ` + 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 Libmodbus archive ...'; ` + tar -zxf $env:TEMP\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 '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; ` + (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; ` + 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...'; ` @@ -243,8 +254,7 @@ RUN Set-Location -Path $env:SystemDrive\.; ` no-shared ` no-ui-console ` no-tests ` - no-unit-test ` -# enable-capieng ` + no-unit-test ` no-capieng ` --api=1.1.0 ` --prefix=$env:BUILD_OUTPUT\openssl ` @@ -252,16 +262,16 @@ RUN Set-Location -Path $env:SystemDrive\.; ` set CL=/MP; ` nmake /S build_sw; ` nmake /S install_dev; ` - nmake /S clean | Out-Null; ` + nmake /S clean | Out-Null; ` Write-Host 'OpenSSL is ready...'; ` - ` + ` Write-Host 'Building PCRE2 library ...'; ` - Set-Location -Path $env:BUILD_SRC\pcre2\build; ` + Set-Location -Path $env:BUILD_SRC\pcre2\build; ` cmake --log-level=ERROR ` -G 'Visual Studio 17 2022' ` - -A $env:BUILD_ARCH ` - -DBUILD_SHARED_LIBS=OFF ` - -DPCRE2_BUILD_TESTS=OFF ` + -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""" ` @@ -270,16 +280,16 @@ RUN Set-Location -Path $env:SystemDrive\.; ` /property:Platform=$env:BUILD_ARCH ` /target:pcre2-8-static; ` ` - 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; ` + 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...'; ` - ` + ` Set-Location -Path $env:BUILD_SRC\libmodbus\src\win32; ` cscript .\configure.js; ` msbuild modbus.vs16.sln ` @@ -287,36 +297,39 @@ RUN Set-Location -Path $env:SystemDrive\.; ` /verbosity:quiet ` /property:Configuration=Release ` /property:Platform=$env:BUILD_ARCH; ` - 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; ` + ` + 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; ` + (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; ` + 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\*; - diff --git a/Dockerfiles/build-mysql/windows/Dockerfile.agent b/Dockerfiles/build-mysql/windows/Dockerfile.agent index 007b3ad2d..ce5983da6 100644 --- a/Dockerfiles/build-mysql/windows/Dockerfile.agent +++ b/Dockerfiles/build-mysql/windows/Dockerfile.agent @@ -6,6 +6,8 @@ ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent-${ZBX_VERSION} FROM ${BUILD_BASE_IMAGE} as builder +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + ARG MAJOR_VERSION ARG ZBX_VERSION ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git @@ -13,7 +15,7 @@ ARG GIT_BRANCH=master ARG ZABBIX_VERSION_RC_NUM=2400 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 + ZABBIX_VERSION_RC_NUM=$ZABBIX_VERSION_RC_NUM LABEL org.opencontainers.image.title="Zabbix agent build (Windows)" ` org.opencontainers.image.authors="Alexey Pustovalov " ` @@ -29,21 +31,27 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPref RUN Set-Location -Path $env:SystemDrive\.; ` ` - Import-Module (Get-ChildItem $env:VS_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName; ` + New-Item -ItemType directory -Path $env:SystemDrive\zabbix_src | Out-Null; ` + New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output | Out-Null; ` + New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\sbin | Out-Null; ` + New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\bin | Out-Null; ` + New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\conf | Out-Null; ` + ` + 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 ('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; ` + git -c advice.detachedHead=false clone $env:ZBX_SOURCES --branch $env:GIT_BRANCH --depth 1 --single-branch $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION; ` ` Write-Host ('Building Zabbix {0} version ...' -f $env:ZBX_VERSION); ` - Set-Location -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION; ` + Set-Location -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION; ` $ZbxRevision=(git rev-parse --short HEAD); ` (Get-Content include/version.h).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content include/version.h; ` - Set-Location -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\build\win32\project; ` + Set-Location -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\build\win32\project; ` set CL=/MP; ` nmake /S -f Makefile ` CPU=$env:CPU_MODEL ` - 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""" ` + 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.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""" ` @@ -51,19 +59,15 @@ RUN Set-Location -Path $env:SystemDrive\.; ` 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""" ` + 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") ...'; ` & $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agentd.exe -V; ` dumpbin /dependents $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agentd.exe; ` ` - New-Item -ItemType directory -Path $env:SystemDrive\zabbix | Out-Null; ` - New-Item -ItemType directory -Path $env:SystemDrive\zabbix\sbin | Out-Null; ` - New-Item -ItemType directory -Path $env:SystemDrive\zabbix\conf | Out-Null; ` - ` - Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agentd.exe $env:SystemDrive\zabbix\sbin; ` - Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_get.exe $env:SystemDrive\zabbix\sbin; ` - Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_sender.exe $env:SystemDrive\zabbix\sbin; ` - Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\conf\zabbix_agentd.win.conf $env:SystemDrive\zabbix\conf; ` + Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agentd.exe $env:SystemDrive\zabbix_output\sbin; ` + Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_get.exe $env:SystemDrive\zabbix_output\bin; ` + Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_sender.exe $env:SystemDrive\zabbix_output\bin; ` + Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\conf\zabbix_agentd.win.conf $env:SystemDrive\zabbix_output\conf\zabbix_agentd.conf; ` Write-Host 'Zabbix binaries are compiled...'; diff --git a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 index 20eecc391..198307280 100644 --- a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 +++ b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 @@ -16,9 +16,10 @@ ARG MONGODB_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mongodb.git ARG POSTGRESQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/postgresql.git ARG GIT_BRANCH=master -ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION GIT_BRANCH=${GIT_BRANCH:-$ZBX_VERSION} ` +ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION ZBX_VERSION=$ZBX_VERSION GIT_BRANCH=${GIT_BRANCH:-$ZBX_VERSION} ` MONGODB_PLUGIN_SOURCES=$MONGODB_PLUGIN_SOURCES MONGODB_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION} ` - POSTGRESQL_PLUGIN_SOURCES=$POSTGRESQL_PLUGIN_SOURCES POSTGRESQL_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION} + POSTGRESQL_PLUGIN_SOURCES=$POSTGRESQL_PLUGIN_SOURCES POSTGRESQL_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION} ` + ZABBIX_VERSION_RC_NUM=$ZABBIX_VERSION_RC_NUM LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" ` org.opencontainers.image.authors="Alexey Pustovalov " `