Updated build process for Zabbix agent (windows)

This commit is contained in:
Alexey Pustovalov 2024-05-18 13:55:00 +09:00
parent 967b97a602
commit b6da3d7569
8 changed files with 471 additions and 409 deletions

View File

@ -29,10 +29,6 @@ SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop';"]
WORKDIR C:\zabbix\
COPY --from=builder ["C:\\zabbix_output", "C:\\zabbix"]
COPY --from=builder ["C:\\mongodb_plugin\\zabbix-agent2-plugin-mongodb.exe", "C:\\zabbix\\zabbix-agent2-plugin\\zabbix-agent2-plugin-mongodb.exe"]
COPY --from=builder ["C:\\mongodb_plugin\\mongodb.conf", "C:\\zabbix\\conf\\zabbix_agentd.d\\mongodb.conf"]
COPY --from=builder ["C:\\postgresql_plugin\\zabbix-agent2-plugin-postgresql.exe", "C:\\zabbix\\zabbix-agent2-plugin\\zabbix-agent2-plugin-postgresql.exe"]
COPY --from=builder ["C:\\postgresql_plugin\\postgresql.conf", "C:\\zabbix\\conf\\zabbix_agentd.d\\postgresql.conf"]
COPY [".\\docker-entrypoint.ps1", "C:\\zabbix"]
USER ContainerAdministrator
@ -42,9 +38,9 @@ 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_agent2.exe -V;
`
Write-Host ('Verifying Zabbix agent 2 {0} ...' -f $env:ZBX_VERSION); `
zabbix_agent2.exe -V;
RUN Set-Location -Path $env:SystemDrive\.; `
`
@ -64,4 +60,4 @@ USER zabbix
EXPOSE 10050/TCP 31999/TCP
CMD C:\zabbix\docker-entrypoint.ps1 C:\zabbix\sbin\zabbix_agent2.exe -c C:\zabbix\conf\zabbix_agent2.win.conf -f
CMD C:\zabbix\docker-entrypoint.ps1 C:\zabbix\sbin\zabbix_agent2.exe -c C:\zabbix\conf\zabbix_agent2.conf -f

View File

@ -6,29 +6,31 @@ FROM $BUILD_BASE_IMAGE as builder_base
ARG PCRE2_VERSION=10.43
ARG OPENSSL_VERSION=3.3.0
ARG GOLANG_VERSION=1.22.3
ARG SEVEN_ZIP_VERSION=2107
ARG SEVEN_ZIP_VERSION=2405
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/17/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 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://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20240507.sfx.exe
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 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
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 `
PCRE2_VERSION=$PCRE2_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
GOLANG_VERSION=$GOLANG_VERSION SEVEN_ZIP_VERSION=$SEVEN_ZIP_VERSION `
GIT_URL=$GIT_URL MSYS2_URL=$MSYS2_URL GOLANG_URL=$GOLANG_URL `
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL `
MINGW_URL=$MINGW_URL SEVEN_ZIP_URL=$SEVEN_ZIP_URL
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL
LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
@ -42,71 +44,75 @@ 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; `
`
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13; `
`
$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\ucrt64\bin', $env:SystemDrive); `
$env:PATH = $env:PATH + [string]::Format(';{0}\msys64\usr\bin;{0}\msys64\ucrt64\bin;{0}\msys64\mingw64\bin', $env:SystemDrive); `
[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); `
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:SEVEN_ZIP_URL); `
Write-Host ('Downloading {0} ...' -f $env:SEVEN_ZIP_URL); `
Invoke-WebRequest -OutFile $env:TEMP\7z.msi -Uri $env:SEVEN_ZIP_URL; `
`
$sha256 = '5447C9AC39C48F1BC7C88359B0520396A8C9707B307C107236A93A68E6FD3EB6'; `
$sha256 = '0F6AA6596D418B1694F62C8583DE05D24589B8D7FFACCE5A7DAB52AE71F832B6'; `
$d_sha256 = (Get-FileHash $env:TEMP\7z.msi -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\7z.msi -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum 7-zip failed!'; `
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-amd64.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; `
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; `
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\go-amd64.zip -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum Go Lang failed!'; `
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; `
`
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 ((Get-FileHash $env:TEMP\mingw.7z -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum Mingw-w64 failed!'; `
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 $env:MSYS2_URL; `
`
$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 ('Downloading {0} ...' -f $env:MSYS2_URL); `
Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $env:MSYS2_URL; `
`
$sha256 = 'D96C53ECBFA4B9D81F6C58077965BB2E31472A8BDA4D4446EF8F45F9C601B11D'; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum MSYS2 failed!'; `
exit 1; `
}; `
`
Write-Host 'Installing GIT...'; `
Expand-Archive `
-Path $env:TEMP\git.zip `
@ -115,36 +121,39 @@ RUN Set-Location -Path $env:SystemDrive\.; `
`
Write-Host 'Verifying install ("git version") ...'; `
git version; `
`
`
Write-Host 'Installing 7z...'; `
Start-Process `
-FilePath $env:TEMP\7z.msi `
-Wait `
-ArgumentList '/qn /norestart'; `
`
`
Write-Host 'Verifying install ("7z -h") ...'; `
7z -h | Select -first 2; `
`
Write-Host 'Installing Go Lang...'; `
Expand-Archive -Path $env:TEMP\go-amd64.zip -DestinationPath $env:SystemDrive\; `
Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; `
`
Write-Host 'Verifying install ("go version") ...'; `
go version; `
`
Write-Host 'Installing Mingw-w64...'; `
`
Write-Host 'Installing Mingw-w64...'; `
7z x $env:TEMP\mingw.7z; `
compact /c /i /s:$env:SystemDrive\mingw64 | Out-Null; `
compact /c /i /s:$env:SystemDrive\mingw64 | Out-Null; `
`
Write-Host 'Verifying install ("gcc -v") ...'; `
gcc -v; `
`
Write-Host 'Installing MSYS2...'; `
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
sh.exe --login -c 'pacman -Syuu --needed --noconfirm --ask=20'; `
sh.exe --login -c 'pacman -Syu --noconfirm'; `
sh.exe --login -c 'pacman --sync --quiet --noconfirm mingw-w64-ucrt-x86_64-cmake'; `
compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; `
`
Write-Host 'Installing MSYS2...'; `
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
sh --login -c 'pacman -Syuu --needed --noconfirm --ask=20'; `
sh --login -c 'pacman -Syu --noconfirm'; `
sh --login -c 'pacman --sync --quiet --noconfirm mingw-w64-ucrt-x86_64-cmake'; `
compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; `
`
Write-Host 'Verifying install ("sh --version") ...'; `
sh.exe --version; `
`
`
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
cmd /C start /w $env:TEMP\vs_buildtools.exe `
--quiet `
@ -162,75 +171,77 @@ RUN Set-Location -Path $env:SystemDrive\.; `
}; `
Wait-Process -name msiexec; `
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
`
$env:VS_PATH = &(Join-Path ${env:ProgramFiles(x86)} """\Microsoft Visual Studio\Installer\vswhere.exe""") -latest -products Microsoft.VisualStudio.Product.BuildTools -property installationPath; `
`
$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); `
`
Write-Host 'Visual Studio components installation cleanup'; `
Write-Host 'Removing downloaded...'; `
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...';
RUN 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; `
Write-Host 'Build environment is ready...'; `
`
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13; `
`
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...'; `
Remove-Item -Force -Path $env:TEMP\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; `
`
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 ...'; `
$env:SystemDirectory = [Environment]::SystemDirectory; `
&("""$env:SystemDirectory\tar.exe""") -zxf "$env:TEMP\openssl.tar.gz"; `
`
Write-Host 'Extracting PCRE2 archive ...'; `
Expand-Archive -Path $env:TEMP\pcre2.zip -DestinationPath $env:BUILD_SRC; `
`
Write-Host 'Removing downloaded ...'; `
Remove-Item -Force -Path $env:TEMP\pcre2.zip; `
Rename-Item -Path $env:BUILD_SRC\pcre2-$env:PCRE2_VERSION -NewName $env:BUILD_SRC\pcre2; `
`
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; `
`
Set-Location -Path $env:BUILD_SRC\pcre2; `
Write-Host 'Building PCRE2 library ...'; `
Set-Location -Path $env:BUILD_SRC\pcre2; `
cmake --log-level=ERROR `
-G 'MinGW Makefiles' `
-DBUILD_SHARED_LIBS=OFF `
-DBUILD_STATIC_LIBS=ON `
-DPCRE2_DEBUG=OFF `
-DPCRE2_BUILD_TESTS=OFF `
-DINSTALL_MSVC_PDB=OFF `
-DBUILD_STATIC_LIBS=ON `
-DPCRE2_DEBUG=OFF `
-DPCRE2_BUILD_TESTS=OFF `
-DINSTALL_MSVC_PDB=OFF `
-DCMAKE_C_COMPILER=gcc `
-DCMAKE_C_FLAGS='-O2 -g' `
-DCMAKE_INSTALL_PREFIX="""$env:BUILD_OUTPUT\pcre2""" . ; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS"""; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install; `
mingw32-make -s clean; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\man -Force -Recurse; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; `
mingw32-make -s clean | Out-Null; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\man -Force -Recurse; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; `
Write-Host 'PCRE2 is ready...'; `
`
Write-Host 'Building OpenSSL library...'; `
@ -240,7 +251,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
no-shared `
no-ui-console `
no-tests `
no-unit-test `
no-unit-test `
no-capieng `
--api=1.1.0 `
--libdir=lib `
@ -248,6 +259,8 @@ RUN Set-Location -Path $env:SystemDrive\.; `
--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; `
Remove-Item -Force -Recurse $env:TEMP\*; `
Write-Host 'OpenSSL is ready...';
mingw32-make -s clean | Out-Null; `
Write-Host 'OpenSSL is ready...'; `
`
Write-Host 'Removing downloaded...'; `
Remove-Item -Force -Recurse $env:TEMP\*;

View File

@ -6,25 +6,27 @@ FROM $BUILD_BASE_IMAGE as builder_base
ARG PCRE2_VERSION=10.43
ARG OPENSSL_VERSION=3.3.0
ARG GOLANG_VERSION=1.22.3
ARG SEVEN_ZIP_VERSION=2107
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/17/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 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://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20240507.sfx.exe
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
ENV ZBX_VERSION=$ZBX_VERSION `
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
GIT_URL=$GIT_URL `
GOLANG_VERSION=$GOLANG_VERSION MSYS2_URL=$MSYS2_URL `
PCRE2_VERSION=$PCRE2_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
GOLANG_VERSION=$GOLANG_VERSION SEVEN_ZIP_VERSION=$SEVEN_ZIP_VERSION `
GIT_URL=$GIT_URL MSYS2_URL=$MSYS2_URL GOLANG_URL=$GOLANG_URL `
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL
LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
@ -39,51 +41,53 @@ 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; `
`
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13; `
`
$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\clang64\bin', $env:SystemDrive); `
$env:PATH = $env:PATH + [string]::Format(';{0}\msys64\usr\bin;{0}\msys64\clang64\bin', $env:SystemDrive); `
[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); `
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:GOLANG_URL); `
Invoke-WebRequest -OutFile $env:TEMP\go-amd64.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; `
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; `
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\go-amd64.zip -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum Go Lang failed!'; `
if ($d_sha256 -ne $sha256) { `
Write-Host ('Checksum Go Lang ({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 ('Downloading {0} ...' -f $env:MSYS2_URL); `
Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $env:MSYS2_URL; `
`
$sha256 = 'D96C53ECBFA4B9D81F6C58077965BB2E31472A8BDA4D4446EF8F45F9C601B11D'; `
Write-Host ('Downloading {0} ...' -f $env:MSYS2_URL); `
Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $env:MSYS2_URL; `
`
$sha256 = 'D96C53ECBFA4B9D81F6C58077965BB2E31472A8BDA4D4446EF8F45F9C601B11D'; `
$d_sha256 = (Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum MSYS2 failed!'; `
Write-Host ('Checksum MSYS2 ({0}) failed!' -f $d_sha256); `
exit 1; `
}; `
`
`
Write-Host 'Installing GIT...'; `
Expand-Archive `
-Path $env:TEMP\git.zip `
@ -92,23 +96,23 @@ RUN Set-Location -Path $env:SystemDrive\.; `
`
Write-Host 'Verifying install ("git version") ...'; `
git version; `
`
`
Write-Host 'Installing Go Lang...'; `
Expand-Archive -Path $env:TEMP\go-amd64.zip -DestinationPath $env:SystemDrive\; `
Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; `
`
Write-Host 'Verifying install ("go version") ...'; `
go version; `
`
Write-Host 'Installing MSYS2...'; `
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
sh.exe --login -c 'pacman -Syuu --needed --noconfirm --ask=20'; `
sh.exe --login -c 'pacman -Syu --noconfirm'; `
sh.exe --login -c 'pacman --sync --quiet --noconfirm mingw-w64-clang-x86_64-gcc-compat mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-make'; `
compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; `
`
Write-Host 'Installing MSYS2...'; `
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
sh --login -c 'pacman -Syuu --needed --noconfirm --ask=20'; `
sh --login -c 'pacman -Syu --noconfirm'; `
sh --login -c 'pacman --sync --quiet --noconfirm mingw-w64-clang-x86_64-gcc-compat mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-make'; `
compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; `
`
Write-Host 'Verifying install ("sh --version") ...'; `
sh.exe --version; `
`
`
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
cmd /C start /w $env:TEMP\vs_buildtools.exe `
--quiet `
@ -126,75 +130,77 @@ RUN Set-Location -Path $env:SystemDrive\.; `
}; `
Wait-Process -name msiexec; `
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
`
$env:VS_PATH = &(Join-Path ${env:ProgramFiles(x86)} """\Microsoft Visual Studio\Installer\vswhere.exe""") -latest -products Microsoft.VisualStudio.Product.BuildTools -property installationPath; `
`
$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); `
`
Write-Host 'Visual Studio components installation cleanup'; `
Write-Host 'Removing downloaded...'; `
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...';
RUN 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; `
Write-Host 'Build environment is ready...'; `
`
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13; `
`
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...'; `
Remove-Item -Force -Path $env:TEMP\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; `
`
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 ...'; `
$env:SystemDirectory = [Environment]::SystemDirectory; `
&("""$env:SystemDirectory\tar.exe""") -zxf "$env:TEMP\openssl.tar.gz"; `
`
Write-Host 'Extracting PCRE2 archive ...'; `
Expand-Archive -Path $env:TEMP\pcre2.zip -DestinationPath $env:BUILD_SRC; `
`
Write-Host 'Removing downloaded ...'; `
Remove-Item -Force -Path $env:TEMP\pcre2.zip; `
Rename-Item -Path $env:BUILD_SRC\pcre2-$env:PCRE2_VERSION -NewName $env:BUILD_SRC\pcre2; `
`
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; `
`
Set-Location -Path $env:BUILD_SRC\pcre2; `
Write-Host 'Building PCRE2 library ...'; `
Set-Location -Path $env:BUILD_SRC\pcre2; `
cmake --log-level=ERROR `
-G 'MinGW Makefiles' `
-DBUILD_SHARED_LIBS=OFF `
-DBUILD_STATIC_LIBS=ON `
-DPCRE2_DEBUG=OFF `
-DPCRE2_BUILD_TESTS=OFF `
-DINSTALL_MSVC_PDB=OFF `
-DBUILD_STATIC_LIBS=ON `
-DPCRE2_DEBUG=OFF `
-DPCRE2_BUILD_TESTS=OFF `
-DINSTALL_MSVC_PDB=OFF `
-DCMAKE_C_COMPILER=gcc `
-DCMAKE_C_FLAGS='-O2 -g' `
-DCMAKE_INSTALL_PREFIX="""$env:BUILD_OUTPUT\pcre2""" . ; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS"""; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install; `
mingw32-make -s clean; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\man -Force -Recurse; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; `
mingw32-make -s clean | Out-Null; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\man -Force -Recurse; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; `
Write-Host 'PCRE2 is ready...'; `
`
Write-Host 'Building OpenSSL library...'; `
@ -204,7 +210,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
no-shared `
no-ui-console `
no-tests `
no-unit-test `
no-unit-test `
no-capieng `
--api=1.1.0 `
--libdir=lib `
@ -212,6 +218,8 @@ RUN Set-Location -Path $env:SystemDrive\.; `
--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; `
Remove-Item -Force -Recurse $env:TEMP\*; `
Write-Host 'OpenSSL is ready...';
mingw32-make -s clean | Out-Null; `
Write-Host 'OpenSSL is ready...'; `
`
Write-Host 'Removing downloaded...'; `
Remove-Item -Force -Recurse $env:TEMP\*;

View File

@ -6,29 +6,31 @@ FROM $BUILD_BASE_IMAGE as builder_base
ARG PCRE2_VERSION=10.43
ARG OPENSSL_VERSION=3.3.0
ARG GOLANG_VERSION=1.22.3
ARG SEVEN_ZIP_VERSION=2107
ARG SEVEN_ZIP_VERSION=2405
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/17/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 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-msvcrt-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://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20240507.sfx.exe
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 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-msvcrt-rt_v11-rev1.7z
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 `
PCRE2_VERSION=$PCRE2_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
GOLANG_VERSION=$GOLANG_VERSION SEVEN_ZIP_VERSION=$SEVEN_ZIP_VERSION `
GIT_URL=$GIT_URL MSYS2_URL=$MSYS2_URL GOLANG_URL=$GOLANG_URL `
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL `
MINGW_URL=$MINGW_URL SEVEN_ZIP_URL=$SEVEN_ZIP_URL
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL
LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
@ -42,70 +44,75 @@ 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; `
`
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13; `
`
$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\mingw64\bin', $env:SystemDrive); `
$env:PATH = $env:PATH + [string]::Format(';{0}\msys64\usr\bin;{0}\msys64\ucrt64\bin;{0}\msys64\mingw64\bin', $env:SystemDrive); `
[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); `
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:SEVEN_ZIP_URL); `
Write-Host ('Downloading {0} ...' -f $env:SEVEN_ZIP_URL); `
Invoke-WebRequest -OutFile $env:TEMP\7z.msi -Uri $env:SEVEN_ZIP_URL; `
`
$sha256 = '5447C9AC39C48F1BC7C88359B0520396A8C9707B307C107236A93A68E6FD3EB6'; `
$sha256 = '0F6AA6596D418B1694F62C8583DE05D24589B8D7FFACCE5A7DAB52AE71F832B6'; `
$d_sha256 = (Get-FileHash $env:TEMP\7z.msi -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\7z.msi -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum 7-zip failed!'; `
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-amd64.zip -Uri $env:GOLANG_URL; `
$sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; `
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; `
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\go-amd64.zip -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum Go Lang failed!'; `
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 = 'e8c65ddc655534b0330f66f7b480565621e8617cda9937d76ba141a22bf3b2fa'; `
Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); `
Invoke-WebRequest -OutFile $env:TEMP\mingw.7z -Uri $env:MINGW_URL; `
`
$sha256 = '15B914F38F2F2E2D6F7B9B8425FF22B7E406878B01920190B09CE0DD8259C6AA'; `
$d_sha256 = (Get-FileHash $env:TEMP\mingw.7z -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\mingw.7z -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum Mingw-w64 failed!'; `
# exit 1; `
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 $env:MSYS2_URL; `
`
$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 ('Downloading {0} ...' -f $env:MSYS2_URL); `
Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $env:MSYS2_URL; `
`
$sha256 = 'D96C53ECBFA4B9D81F6C58077965BB2E31472A8BDA4D4446EF8F45F9C601B11D'; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum MSYS2 failed!'; `
exit 1; `
}; `
`
Write-Host 'Installing GIT...'; `
Expand-Archive `
-Path $env:TEMP\git.zip `
@ -114,35 +121,39 @@ RUN Set-Location -Path $env:SystemDrive\.; `
`
Write-Host 'Verifying install ("git version") ...'; `
git version; `
`
`
Write-Host 'Installing 7z...'; `
Start-Process `
-FilePath $env:TEMP\7z.msi `
-Wait `
-ArgumentList '/qn /norestart'; `
`
`
Write-Host 'Verifying install ("7z -h") ...'; `
7z -h | Select -first 2; `
`
Write-Host 'Installing Go Lang...'; `
Expand-Archive -Path $env:TEMP\go-amd64.zip -DestinationPath $env:SystemDrive\; `
Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; `
`
Write-Host 'Verifying install ("go version") ...'; `
go version; `
`
Write-Host 'Installing Mingw-w64...'; `
`
Write-Host 'Installing Mingw-w64...'; `
7z x $env:TEMP\mingw.7z; `
compact /c /i /s:$env:SystemDrive\mingw64 | Out-Null; `
`
Write-Host 'Verifying install ("gcc -v") ...'; `
gcc -v; `
`
Write-Host 'Installing MSYS2...'; `
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
sh.exe --login -c 'pacman -Syuu --needed --noconfirm --ask=20'; `
sh.exe --login -c 'pacman -Syu --noconfirm'; `
sh.exe --login -c 'pacman --sync --quiet --noconfirm mingw-w64-x86_64-cmake'; `
compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; `
`
Write-Host 'Installing MSYS2...'; `
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
sh --login -c 'pacman -Syuu --needed --noconfirm --ask=20'; `
sh --login -c 'pacman -Syu --noconfirm'; `
sh --login -c 'pacman --sync --quiet --noconfirm mingw-w64-x86_64-cmake'; `
compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; `
`
Write-Host 'Verifying install ("sh --version") ...'; `
sh.exe --version; `
`
`
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
cmd /C start /w $env:TEMP\vs_buildtools.exe `
--quiet `
@ -160,75 +171,77 @@ RUN Set-Location -Path $env:SystemDrive\.; `
}; `
Wait-Process -name msiexec; `
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
`
$env:VS_PATH = &(Join-Path ${env:ProgramFiles(x86)} """\Microsoft Visual Studio\Installer\vswhere.exe""") -latest -products Microsoft.VisualStudio.Product.BuildTools -property installationPath; `
`
$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); `
`
Write-Host 'Visual Studio components installation cleanup'; `
Write-Host 'Removing downloaded...'; `
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...';
RUN 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; `
Write-Host 'Build environment is ready...'; `
Set-Location -Path $env:SystemDrive\.; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13; `
`
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...'; `
Remove-Item -Force -Path $env:TEMP\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; `
`
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 ...'; `
$env:SystemDirectory = [Environment]::SystemDirectory; `
&("""$env:SystemDirectory\tar.exe""") -zxf "$env:TEMP\openssl.tar.gz"; `
`
Write-Host 'Extracting PCRE2 archive ...'; `
Expand-Archive -Path $env:TEMP\pcre2.zip -DestinationPath $env:BUILD_SRC; `
`
Write-Host 'Removing downloaded ...'; `
Remove-Item -Force -Path $env:TEMP\pcre2.zip; `
Rename-Item -Path $env:BUILD_SRC\pcre2-$env:PCRE2_VERSION -NewName $env:BUILD_SRC\pcre2; `
`
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; `
`
Set-Location -Path $env:BUILD_SRC\pcre2; `
Write-Host 'Building PCRE2 library ...'; `
Set-Location -Path $env:BUILD_SRC\pcre2; `
New-Item -ItemType directory -Path "$env:BUILD_SRC\pcre2\build" | Out-Null; `
cmake --log-level=ERROR `
-G 'MinGW Makefiles' `
-DBUILD_SHARED_LIBS=OFF `
-DBUILD_STATIC_LIBS=ON `
-DPCRE2_DEBUG=OFF `
-DPCRE2_BUILD_TESTS=OFF `
-DINSTALL_MSVC_PDB=OFF `
-DBUILD_STATIC_LIBS=ON `
-DPCRE2_DEBUG=OFF `
-DPCRE2_BUILD_TESTS=OFF `
-DINSTALL_MSVC_PDB=OFF `
-DCMAKE_C_COMPILER=gcc `
-DCMAKE_C_FLAGS='-O2 -g' `
-DCMAKE_INSTALL_PREFIX="""$env:BUILD_OUTPUT\pcre2""" . ; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS"""; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install; `
mingw32-make -s clean; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\man -Force -Recurse; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; `
mingw32-make -s clean | Out-Null; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\man -Force -Recurse; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; `
Write-Host 'PCRE2 is ready...'; `
`
Write-Host 'Building OpenSSL library...'; `
@ -238,7 +251,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
no-shared `
no-ui-console `
no-tests `
no-unit-test `
no-unit-test `
no-capieng `
--api=1.1.0 `
--libdir=lib `
@ -246,6 +259,8 @@ RUN Set-Location -Path $env:SystemDrive\.; `
--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; `
Remove-Item -Force -Recurse $env:TEMP\*; `
Write-Host 'OpenSSL is ready...';
mingw32-make -s clean | Out-Null; `
Write-Host 'OpenSSL is ready...'; `
`
Write-Host 'Removing downloaded...'; `
Remove-Item -Force -Recurse $env:TEMP\*;

View File

@ -3,28 +3,26 @@
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
FROM $BUILD_BASE_IMAGE as builder_base
ARG PCRE2_VERSION=10.43
ARG OPENSSL_VERSION=3.3.0
ARG GOLANG_VERSION=1.22.3
ARG SEVEN_ZIP_VERSION=2107
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/17/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 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 LLVM_MINGW=https://github.com/mstorsjo/llvm-mingw/releases/download/20240502/llvm-mingw-20240502-ucrt-x86_64.zip
ARG VCPKG_GIT=https://github.com/microsoft/vcpkg
ENV ZBX_VERSION=$ZBX_VERSION `
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
GOLANG_VERSION=$GOLANG_VERSION `
GIT_URL=$GIT_URL GOLANG_URL=$GOLANG_URL `
LLVM_MINGW=$LLVM_MINGW VCPKG_GIT=$VCPKG_GIT `
VCPKG_BINARY_SOURCES=clear VCPKG_DEFAULT_TRIPLET=$BUILD_ARCH-mingw-static-release
GIT_URL=$GIT_URL `
GOLANG_VERSION=$GOLANG_VERSION LLVM_MINGW=$LLVM_MINGW VCPKG_GIT=$VCPKG_GIT `
VCPKG_BINARY_SOURCES=clear VCPKG_DEFAULT_TRIPLET=$BUILD_ARCH-mingw-static-release
LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
@ -38,48 +36,49 @@ 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; `
`
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13; `
`
$env:PATH = [string]::Format('{0}\vcpkg;{0}\llvm_mingw\bin;{0}\go\bin;{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); `
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:GOLANG_URL); `
Invoke-WebRequest -OutFile $env:TEMP\go-amd64.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; `
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'; `
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\go-amd64.zip -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum Go Lang failed!'; `
if ($d_sha256 -ne $sha256) { `
Write-Host ('Checksum Go Lang ({0}) failed!' -f $d_sha256); `
exit 1; `
}; `
`
`
Write-Host ('Downloading {0} ...' -f $env:LLVM_MINGW); `
Invoke-WebRequest -OutFile $env:TEMP\llvm_mingw.zip -Uri $env:LLVM_MINGW; `
`
$sha256 = '2487683A7341FFA4D0C1D107268D22DC722A43EA2E7C7F46DA0648E34F4F4C8B'; `
`
$sha256 = '2487683A7341FFA4D0C1D107268D22DC722A43EA2E7C7F46DA0648E34F4F4C8B'; `
$d_sha256 = (Get-FileHash $env:TEMP\llvm_mingw.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\llvm_mingw.zip -Algorithm sha256).Hash -ne $sha256) { `
Write-Host 'Checksum Go Lang failed!'; `
Write-Host ('Checksum LLVM MinGW ({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; `
`
@ -91,18 +90,19 @@ RUN Set-Location -Path $env:SystemDrive\.; `
`
Write-Host 'Verifying install ("git version") ...'; `
git version; `
`
Write-Host 'Installing Go Lang...'; `
Expand-Archive -Path $env:TEMP\go-amd64.zip -DestinationPath $env:SystemDrive\; `
`
Write-Host 'Installing Go Lang...'; `
Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; `
Write-Host 'Verifying install ("go version") ...'; `
go version; `
`
`
Write-Host 'Installing LLVM Mingw...'; `
Expand-Archive -Path $env:TEMP\llvm_mingw.zip -DestinationPath $env:SystemDrive\; `
Move-Item -Path $env:SystemDrive\llvm-mingw-20240502-ucrt-x86_64\ -Destination $env:SystemDrive\llvm_mingw; `
`
`
Write-Host 'Installing LLVM MinGW ...'; `
Expand-Archive -Path $env:TEMP\llvm_mingw.zip -DestinationPath $env:SystemDrive\; `
Move-Item -Path $env:SystemDrive\llvm-mingw-20240502-ucrt-x86_64\ -Destination $env:SystemDrive\llvm_mingw; `
`
Write-Host 'Verifying install ("git version") ...'; `
gcc -v; `
`
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
cmd /C start /w $env:TEMP\vs_buildtools.exe `
--quiet `
@ -120,21 +120,22 @@ RUN Set-Location -Path $env:SystemDrive\.; `
}; `
Wait-Process -name msiexec; `
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
`
$env:VS_PATH = &(Join-Path ${env:ProgramFiles(x86)} """\Microsoft Visual Studio\Installer\vswhere.exe""") -latest -products Microsoft.VisualStudio.Product.BuildTools -property installationPath; `
`
$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); `
`
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 'Installing Vcpkg...'; `
$env:VCPKG_DEFAULT_BINARY_CACHE = $env:TEMP; `
git clone $env:VCPKG_GIT $env:SystemDrive\vcpkg; `
& $env:SystemDrive\vcpkg\bootstrap-vcpkg.bat -disableMetrics; `
Copy-Item $env:SystemDrive\vcpkg\triplets\community\$env:BUILD_ARCH-mingw-static.cmake -Destination $env:SystemDrive\vcpkg\triplets\community\$env:VCPKG_DEFAULT_TRIPLET.cmake; `
Add-Content -Path $env:SystemDrive\vcpkg\triplets\community\$env:VCPKG_DEFAULT_TRIPLET.cmake -Value """set(VCPKG_BUILD_TYPE release)"""; `
Write-Host 'Installing dependencies...'; `
vcpkg install libiconv pcre2 openssl; `
Write-Host 'Removing downloaded...'; `
`
Write-Host 'Installing Vcpkg ...'; `
$env:VCPKG_DEFAULT_BINARY_CACHE = $env:TEMP; `
git clone $env:VCPKG_GIT $env:SystemDrive\vcpkg; `
& $env:SystemDrive\vcpkg\bootstrap-vcpkg.bat -disableMetrics; `
Copy-Item $env:SystemDrive\vcpkg\triplets\community\$env:BUILD_ARCH-mingw-static.cmake -Destination $env:SystemDrive\vcpkg\triplets\community\$env:VCPKG_DEFAULT_TRIPLET.cmake; `
Add-Content -Path $env:SystemDrive\vcpkg\triplets\community\$env:VCPKG_DEFAULT_TRIPLET.cmake -Value """set(VCPKG_BUILD_TYPE release)"""; `
Write-Host 'Installing dependencies ...'; `
vcpkg install libiconv pcre2 openssl; `
`
Write-Host 'Removing downloaded ...'; `
Remove-Item -Force -Recurse $env:TEMP\*; `
Write-Host 'Build environment is ready...';

View File

@ -12,11 +12,13 @@ ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG ZABBIX_VERSION_RC_NUM=2400
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
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} `
MONGODB_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mongodb.git MONGODB_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION} `
POSTGRESQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/postgresql.git POSTGRESQL_PLUGIN_VERSION=${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}
LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
@ -30,51 +32,60 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
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\conf | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\conf\zabbix_agentd.d | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\zabbix-agent2-plugin | 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; `
(Get-Content src\go\pkg\version\version.go).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content src\go\pkg\version\version.go; `
Set-Location -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\build\mingw; `
Set-Location -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\build\mingw; `
mingw32-make -j"""$env:NUMBER_OF_PROCESSORS""" `
CGO_LDFLAGS="""-lcrypt32 -L$env:BUILD_OUTPUT\openssl\lib -L$env:BUILD_OUTPUT\pcre2\lib""" `
CGO_LDFLAGS="""-lcrypt32 -L$env:BUILD_OUTPUT\openssl\lib -L$env:BUILD_OUTPUT\pcre2\lib""" `
PCRE2=$env:BUILD_OUTPUT\pcre2 `
OPENSSL=$env:BUILD_OUTPUT\openssl `
RFLAGS="""-DZABBIX_VERSION_RC_NUM=2400"""; `
RFLAGS="""-DZABBIX_VERSION_RC_NUM=$env:ZABBIX_VERSION_RC_NUM"""; `
`
Write-Host 'Verifying build ("zabbix_agent2.exe -V") ...'; `
& $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe -V; `
dumpbin /dependents $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe; `
& $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe -V; `
dumpbin /dependents $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe; `
`
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2 | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2\sbin | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2\conf | Out-Null; `
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe $env:SystemDrive\zabbix_output\sbin; `
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\src\go\conf\zabbix_agent2.win.conf $env:SystemDrive\zabbix_output\conf\zabbix_agent2.conf; `
mingw32-make -s clean; `
`
Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe $env:SystemDrive\zabbix2\sbin; `
Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\src\go\conf\zabbix_agent2.win.conf $env:SystemDrive\zabbix2\conf; `
mingw32-make -s clean; `
`
Set-Location -Path $env:SystemDrive; `
Write-Host ('Building Zabbix MongoDB plugin {0} version ...' -f $env:MONGODB_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:MONGODB_PLUGIN_SOURCES --branch $env:MONGODB_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\mongodb_plugin; `
Set-Location -Path $env:SystemDrive\mongodb_plugin; `
git -c advice.detachedHead=false clone $env:MONGODB_PLUGIN_SOURCES --branch $env:MONGODB_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\zabbix_src\mongodb_plugin; `
Set-Location -Path $env:SystemDrive\zabbix_src\mongodb_plugin; `
mingw32-make; `
mv $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe; `
Write-Host 'Verifying build ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
& $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe -V; `
`
Set-Location -Path $env:SystemDrive; `
Write-Host 'Verifying MongoDB plugin ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
& $env:SystemDrive\zabbix_src\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe -V; `
`
Copy-Item -Path $env:SystemDrive\zabbix_src\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe $env:SystemDrive\zabbix_output\zabbix-agent2-plugin; `
Copy-Item -Path $env:SystemDrive\zabbix_src\mongodb_plugin\mongodb.conf $env:SystemDrive\zabbix_output\conf\zabbix_agentd.d; `
mingw32-make -s clean; `
`
Write-Host ('Building Zabbix PostgreSQL plugin {0} version ...' -f $env:POSTGRESQL_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:POSTGRESQL_PLUGIN_SOURCES --branch $env:POSTGRESQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\postgresql_plugin; `
Set-Location -Path $env:SystemDrive\postgresql_plugin; `
git -c advice.detachedHead=false clone $env:POSTGRESQL_PLUGIN_SOURCES --branch $env:POSTGRESQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\zabbix_src\postgresql_plugin; `
Set-Location -Path $env:SystemDrive\zabbix_src\postgresql_plugin; `
mingw32-make; `
mv $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe; `
`
Write-Host 'Verifying build ("zabbix-agent2-plugin-postgresql.exe -V") ...'; `
& $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe -V; `
Remove-Item -Recurse -Force -Path $(go env GOCACHE); `
& $env:SystemDrive\zabbix_src\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe -V; `
`
Copy-Item -Path $env:SystemDrive\zabbix_src\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe $env:SystemDrive\zabbix_output\zabbix-agent2-plugin; `
Copy-Item -Path $env:SystemDrive\zabbix_src\postgresql_plugin\postgresql.conf $env:SystemDrive\zabbix_output\conf\zabbix_agentd.d; `
mingw32-make -s clean; `
Write-Host 'Zabbix binaries are compiled...';

View File

@ -12,11 +12,13 @@ ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG ZABBIX_VERSION_RC_NUM=2400
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
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} `
MONGODB_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mongodb.git MONGODB_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION} `
POSTGRESQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/postgresql.git POSTGRESQL_PLUGIN_VERSION=${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}
LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
@ -30,52 +32,60 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
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\conf | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\conf\zabbix_agentd.d | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\zabbix-agent2-plugin | 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; `
(Get-Content include\version.h).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content include\version.h; `
(Get-Content src\go\pkg\version\version.go).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content src\go\pkg\version\version.go; `
Set-Location -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\build\mingw; `
Set-Location -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\build\mingw; `
mingw32-make -j"""$env:NUMBER_OF_PROCESSORS""" `
CGO_LDFLAGS="""-l:libiconv.a -lcrypt32 -L$env:BUILD_OUTPUT\openssl\lib -L$env:BUILD_OUTPUT\pcre2\lib""" `
PCRE2=$env:BUILD_OUTPUT\pcre2 `
CGO_LDFLAGS="""-l:libiconv.a -lcrypt32 -L$env:BUILD_OUTPUT\openssl\lib -L$env:BUILD_OUTPUT\pcre2\lib""" `
PCRE2=$env:BUILD_OUTPUT\pcre2 `
OPENSSL=$env:BUILD_OUTPUT\openssl `
RFLAGS="""-DZABBIX_VERSION_RC_NUM=2400"""; `
RFLAGS="""-DZABBIX_VERSION_RC_NUM=$env:ZABBIX_VERSION_RC_NUM"""; `
`
Write-Host 'Verifying build ("zabbix_agent2.exe -V") ...'; `
& $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe -V; `
dumpbin /dependents $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe; `
& $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe -V; `
dumpbin /dependents $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe; `
`
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2 | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2\sbin | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2\conf | Out-Null; `
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe $env:SystemDrive\zabbix_output\sbin; `
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\src\go\conf\zabbix_agent2.win.conf $env:SystemDrive\zabbix_output\conf\zabbix_agent2.conf; `
mingw32-make -s clean; `
`
Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe $env:SystemDrive\zabbix2\sbin; `
Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\src\go\conf\zabbix_agent2.win.conf $env:SystemDrive\zabbix2\conf; `
mingw32-make -s clean; `
`
Set-Location -Path $env:SystemDrive; `
Write-Host ('Building Zabbix MongoDB plugin {0} version ...' -f $env:MONGODB_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:MONGODB_PLUGIN_SOURCES --branch $env:MONGODB_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\mongodb_plugin; `
Set-Location -Path $env:SystemDrive\mongodb_plugin; `
git -c advice.detachedHead=false clone $env:MONGODB_PLUGIN_SOURCES --branch $env:MONGODB_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\zabbix_src\mongodb_plugin; `
Set-Location -Path $env:SystemDrive\zabbix_src\mongodb_plugin; `
mingw32-make; `
mv $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe; `
Write-Host 'Verifying build ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
& $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe -V; `
`
Set-Location -Path $env:SystemDrive; `
Write-Host 'Verifying MongoDB plugin ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
& $env:SystemDrive\zabbix_src\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe -V; `
`
Copy-Item -Path $env:SystemDrive\zabbix_src\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe $env:SystemDrive\zabbix_output\zabbix-agent2-plugin; `
Copy-Item -Path $env:SystemDrive\zabbix_src\mongodb_plugin\mongodb.conf $env:SystemDrive\zabbix_output\conf\zabbix_agentd.d; `
mingw32-make -s clean; `
`
Write-Host ('Building Zabbix PostgreSQL plugin {0} version ...' -f $env:POSTGRESQL_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:POSTGRESQL_PLUGIN_SOURCES --branch $env:POSTGRESQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\postgresql_plugin; `
Set-Location -Path $env:SystemDrive\postgresql_plugin; `
git -c advice.detachedHead=false clone $env:POSTGRESQL_PLUGIN_SOURCES --branch $env:POSTGRESQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\zabbix_src\postgresql_plugin; `
Set-Location -Path $env:SystemDrive\zabbix_src\postgresql_plugin; `
mingw32-make; `
mv $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe; `
`
Write-Host 'Verifying build ("zabbix-agent2-plugin-postgresql.exe -V") ...'; `
& $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe -V; `
Remove-Item -Recurse -Force -Path $(go env GOCACHE); `
& $env:SystemDrive\zabbix_src\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe -V; `
`
Copy-Item -Path $env:SystemDrive\zabbix_src\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe $env:SystemDrive\zabbix_output\zabbix-agent2-plugin; `
Copy-Item -Path $env:SystemDrive\zabbix_src\postgresql_plugin\postgresql.conf $env:SystemDrive\zabbix_output\conf\zabbix_agentd.d; `
mingw32-make -s clean; `
Write-Host 'Zabbix binaries are compiled...';

View File

@ -12,11 +12,13 @@ ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG ZABBIX_VERSION_RC_NUM=2400
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
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} `
MONGODB_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mongodb.git MONGODB_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION} `
POSTGRESQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/postgresql.git POSTGRESQL_PLUGIN_VERSION=${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}
LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
@ -30,55 +32,61 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
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\conf | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\conf\zabbix_agentd.d | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\zabbix-agent2-plugin | 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; `
(Get-Content include\version.h).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content include\version.h; `
(Get-Content src\go\pkg\version\version.go).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content src\go\pkg\version\version.go; `
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"""; `
Set-Location -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\build\mingw; `
Set-Location -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\build\mingw; `
mingw32-make -j"""$env:NUMBER_OF_PROCESSORS""" `
GOFLAGS="""-buildvcs=false""" `
CGO_LDFLAGS="""-lcrypt32 -L$env:SystemDrive\vcpkg\installed\x64-mingw-static-release\lib""" `
PCRE2=$env:SystemDrive\vcpkg\installed\x64-mingw-static-release `
GOFLAGS="""-buildvcs=false""" `
CGO_LDFLAGS="""-lcrypt32 -L$env:SystemDrive\vcpkg\installed\x64-mingw-static-release\lib""" `
PCRE2=$env:SystemDrive\vcpkg\installed\x64-mingw-static-release `
OPENSSL=$env:SystemDrive\vcpkg\installed\x64-mingw-static-release `
RFLAGS="""-DZABBIX_VERSION_RC_NUM=2400"""; `
RFLAGS="""-DZABBIX_VERSION_RC_NUM=$env:ZABBIX_VERSION_RC_NUM"""; `
`
Write-Host 'Verifying build ("zabbix_agent2.exe -V") ...'; `
& $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe -V; `
dumpbin /dependents $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe; `
& $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe -V; `
dumpbin /dependents $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe; `
`
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2 | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2\sbin | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2\conf | Out-Null; `
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe $env:SystemDrive\zabbix_output\sbin; `
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\src\go\conf\zabbix_agent2.win.conf $env:SystemDrive\zabbix_output\conf\zabbix_agent2.conf; `
mingw32-make -s clean; `
`
Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe $env:SystemDrive\zabbix2\sbin; `
Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\src\go\conf\zabbix_agent2.win.conf $env:SystemDrive\zabbix2\conf; `
mingw32-make -s clean; `
`
Set-Location -Path $env:SystemDrive; `
Write-Host ('Building Zabbix MongoDB plugin {0} version ...' -f $env:MONGODB_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:MONGODB_PLUGIN_SOURCES --branch $env:MONGODB_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\mongodb_plugin; `
Set-Location -Path $env:SystemDrive\mongodb_plugin; `
git -c advice.detachedHead=false clone $env:MONGODB_PLUGIN_SOURCES --branch $env:MONGODB_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\zabbix_src\mongodb_plugin; `
Set-Location -Path $env:SystemDrive\zabbix_src\mongodb_plugin; `
mingw32-make; `
mv $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe; `
Write-Host 'Verifying build ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
& $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe -V; `
`
Set-Location -Path $env:SystemDrive; `
Write-Host 'Verifying MongoDB plugin ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
& $env:SystemDrive\zabbix_src\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe -V; `
`
Copy-Item -Path $env:SystemDrive\zabbix_src\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe $env:SystemDrive\zabbix_output\zabbix-agent2-plugin; `
Copy-Item -Path $env:SystemDrive\zabbix_src\mongodb_plugin\mongodb.conf $env:SystemDrive\zabbix_output\conf\zabbix_agentd.d; `
mingw32-make -s clean; `
`
Write-Host ('Building Zabbix PostgreSQL plugin {0} version ...' -f $env:POSTGRESQL_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:POSTGRESQL_PLUGIN_SOURCES --branch $env:POSTGRESQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\postgresql_plugin; `
Set-Location -Path $env:SystemDrive\postgresql_plugin; `
git -c advice.detachedHead=false clone $env:POSTGRESQL_PLUGIN_SOURCES --branch $env:POSTGRESQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\zabbix_src\postgresql_plugin; `
Set-Location -Path $env:SystemDrive\zabbix_src\postgresql_plugin; `
mingw32-make; `
mv $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe; `
`
Write-Host 'Verifying build ("zabbix-agent2-plugin-postgresql.exe -V") ...'; `
& $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe -V; `
Remove-Item -Recurse -Force -Path $(go env GOCACHE); `
& $env:SystemDrive\zabbix_src\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe -V; `
`
Copy-Item -Path $env:SystemDrive\zabbix_src\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe $env:SystemDrive\zabbix_output\zabbix-agent2-plugin; `
Copy-Item -Path $env:SystemDrive\zabbix_src\postgresql_plugin\postgresql.conf $env:SystemDrive\zabbix_output\conf\zabbix_agentd.d; `
mingw32-make -s clean; `
Write-Host 'Zabbix binaries are compiled...';