2021-09-17 22:35:50 +02:00
|
|
|
# syntax=docker/dockerfile:1
|
|
|
|
# escape=`
|
2021-11-13 01:27:21 +01:00
|
|
|
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
|
2021-09-17 22:35:50 +02:00
|
|
|
FROM $BUILD_BASE_IMAGE
|
|
|
|
|
2022-01-21 21:56:51 +01:00
|
|
|
ARG PCRE2_VERSION=10.39
|
2023-02-27 10:26:11 +01:00
|
|
|
ARG OPENSSL_VERSION=3.0.8
|
2022-03-02 11:37:08 +01:00
|
|
|
ARG LIBMODBUS_VERSION=v3.1.7
|
2021-09-17 22:35:50 +02:00
|
|
|
ARG BUILD_ARCH=x64
|
|
|
|
ARG CPU_MODEL=AMD64
|
|
|
|
|
2022-07-05 14:46:20 +02:00
|
|
|
ARG MAJOR_VERSION=6.4
|
2024-01-29 12:58:57 +01:00
|
|
|
ARG ZBX_VERSION=${MAJOR_VERSION}.11
|
2021-09-17 22:35:50 +02:00
|
|
|
|
|
|
|
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
|
2022-01-21 21:56:51 +01:00
|
|
|
ARG PCRE2_URL=https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.zip
|
2021-09-17 22:35:50 +02:00
|
|
|
ARG OPENSSL_URL=https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
|
|
|
|
ARG LIBMODBUS_URL=https://github.com/stephane/libmodbus.git
|
|
|
|
|
2021-10-16 17:49:19 +02:00
|
|
|
ENV ZBX_VERSION=$ZBX_VERSION `
|
|
|
|
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
|
2022-01-21 21:56:51 +01:00
|
|
|
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
|
2021-09-17 22:35:50 +02:00
|
|
|
|
2021-09-18 03:08:26 +02:00
|
|
|
LABEL org.opencontainers.image.title="Zabbix agent build base for Windows" `
|
|
|
|
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
|
|
|
org.opencontainers.image.vendor="Zabbix LLC" `
|
|
|
|
org.opencontainers.image.url="https://zabbix.com/" `
|
|
|
|
org.opencontainers.image.description="Zabbix build base image contains all required packages to build Zabbix agent images" `
|
|
|
|
org.opencontainers.image.licenses="GPL v2.0" `
|
|
|
|
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
|
2021-10-16 17:49:19 +02:00
|
|
|
org.opencontainers.image.version="${ZBX_VERSION}"
|
2021-09-17 22:35:50 +02:00
|
|
|
|
|
|
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
|
|
|
|
|
|
|
RUN Set-Location -Path $env:SystemDrive\.; `
|
|
|
|
`
|
|
|
|
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; `
|
|
|
|
`
|
|
|
|
$sha256 = '273f55e881094d00877d64f56570b0c997c4da5dedcb26738d56481033c1eba1'; `
|
|
|
|
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!'; `
|
|
|
|
exit 1; `
|
|
|
|
}; `
|
|
|
|
`
|
|
|
|
Write-Host 'Installing ...'; `
|
|
|
|
Expand-Archive `
|
|
|
|
-Path git.zip `
|
|
|
|
-DestinationPath $env:SystemDrive\git\.; `
|
2021-09-24 22:55:53 +02:00
|
|
|
Write-Host 'Removing downloaded...'; `
|
2021-09-17 22:35:50 +02:00
|
|
|
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 ...'; `
|
|
|
|
Start-Process `
|
|
|
|
-FilePath $env:SystemDrive\nasm_installer.exe `
|
|
|
|
-ArgumentList '/S' -Wait; `
|
2021-09-24 22:55:53 +02:00
|
|
|
Write-Host 'Removing downloaded...'; `
|
2021-09-17 22:35:50 +02:00
|
|
|
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; `
|
2021-09-24 22:55:53 +02:00
|
|
|
Write-Host 'Removing downloaded...'; `
|
2021-09-17 22:35:50 +02:00
|
|
|
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 'Verifying install ("perl -V") ...'; `
|
|
|
|
perl -V; `
|
|
|
|
`
|
|
|
|
Write-Host 'Installing Text::Template...'; `
|
|
|
|
cpan Text::Template; `
|
2021-11-13 18:41:16 +01:00
|
|
|
`
|
2021-09-17 22:35:50 +02:00
|
|
|
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 `
|
2021-11-13 01:27:21 +01:00
|
|
|
--nocache `
|
2021-09-17 22:35:50 +02:00
|
|
|
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\BuildTools""" `
|
2021-11-13 01:27:21 +01:00
|
|
|
--channelUri https://aka.ms/vs/16/release/channel `
|
|
|
|
--installChannelUri https://aka.ms/vs/16/release/channel `
|
|
|
|
--channelId VisualStudio.16.Release `
|
2021-09-17 22:35:50 +02:00
|
|
|
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019
|
|
|
|
--add Microsoft.VisualStudio.Component.Windows10SDK.19041 `
|
|
|
|
--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; `
|
|
|
|
}; `
|
|
|
|
Wait-Process -name msiexec; `
|
|
|
|
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
|
|
|
|
`
|
|
|
|
Write-Host 'Visual Studio components installation cleanup'; `
|
2021-09-24 22:55:53 +02:00
|
|
|
Write-Host 'Removing downloaded...'; `
|
2021-09-17 22:35:50 +02:00
|
|
|
Remove-Item -Force -Path $env:SystemDrive\vs_buildtools.exe; `
|
2021-11-13 18:42:56 +01:00
|
|
|
Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; `
|
2021-09-17 22:35:50 +02:00
|
|
|
Remove-Item -Force -Recurse $env:TEMP\*; `
|
|
|
|
Write-Host 'Build environment 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"""; `
|
|
|
|
`
|
2022-01-21 21:56:51 +01:00
|
|
|
Write-Host ('Downloading {0} ...' -f $env:PCRE2_URL); `
|
2021-09-17 22:35:50 +02:00
|
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
2022-01-21 21:56:51 +01:00
|
|
|
Invoke-WebRequest -OutFile $env:SystemDrive\pcre2.zip -Uri $env:PCRE2_URL; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
2022-01-21 21:56:51 +01:00
|
|
|
$sha256 = '08a8861f60fec3af30ca1e0f51d89ab5dc5c07bb71b74db5297f78b7e26c7226'; `
|
2021-09-17 22:35:50 +02:00
|
|
|
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
2022-01-21 21:56:51 +01:00
|
|
|
if ((Get-FileHash $env:SystemDrive\pcre2.zip -Algorithm sha256).Hash -ne $sha256) { `
|
|
|
|
Write-Host 'Checksum PCRE2 library failed!'; `
|
2021-09-17 22:35:50 +02:00
|
|
|
exit 1; `
|
|
|
|
}; `
|
|
|
|
Write-Host 'Extracting archive ...'; `
|
2022-01-21 21:56:51 +01:00
|
|
|
Expand-Archive -Path $env:SystemDrive\pcre2.zip -DestinationPath $env:SystemDrive; `
|
2021-09-24 22:55:53 +02:00
|
|
|
Write-Host 'Removing downloaded...'; `
|
2022-01-21 21:56:51 +01:00
|
|
|
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; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
2022-01-21 21:56:51 +01:00
|
|
|
Set-Location -Path $env:SystemDrive\pcre2_build\build; `
|
|
|
|
Write-Host 'Building PCRE2 library ...'; `
|
2021-09-17 22:35:50 +02:00
|
|
|
cmake --log-level=ERROR `
|
|
|
|
-G 'Visual Studio 16 2019' `
|
|
|
|
-A $env:BUILD_ARCH `
|
2022-01-22 13:35:18 +01:00
|
|
|
-DBUILD_SHARED_LIBS=OFF `
|
2021-09-17 22:35:50 +02:00
|
|
|
-DCMAKE_C_FLAGS_RELEASE:string="""/MT""" ..; `
|
2022-01-21 21:56:51 +01:00
|
|
|
msbuild PCRE2.sln `
|
2021-09-17 22:35:50 +02:00
|
|
|
-maxcpucount:"""$env:NUMBER_OF_PROCESSORS""" `
|
|
|
|
/verbosity:quiet `
|
|
|
|
/property:Configuration=Release `
|
|
|
|
/property:Platform=$env:BUILD_ARCH `
|
2022-01-21 21:56:51 +01:00
|
|
|
/target:pcre2-8-static; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
2022-01-21 21:56:51 +01:00
|
|
|
Write-Host 'PCRE2 is ready...';
|
2021-09-17 22:35:50 +02:00
|
|
|
|
|
|
|
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; `
|
|
|
|
`
|
2023-02-27 10:51:37 +01:00
|
|
|
$sha256 = '6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e'; `
|
2021-09-17 22:35:50 +02:00
|
|
|
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; `
|
2021-09-24 22:55:53 +02:00
|
|
|
Write-Host 'Removing downloaded...'; `
|
2021-09-17 22:35:50 +02:00
|
|
|
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; `
|
2022-05-09 13:19:26 +02:00
|
|
|
nmake /S build_sw; `
|
|
|
|
nmake /S install_dev; `
|
2021-09-17 22:35:50 +02:00
|
|
|
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; `
|
|
|
|
`
|
|
|
|
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; `
|
|
|
|
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...';
|