Updated build procedure for Windows containers

This commit is contained in:
Alexey Pustovalov 2025-01-10 19:25:23 +09:00
parent 8ad3e9f990
commit f3fe843b85
12 changed files with 19 additions and 806 deletions

View File

@ -249,7 +249,7 @@ jobs:
Write-Host @"
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION
--label org.opencontainers.image.created=$Env:LABEL_CREATED
--build-arg=BUILD_BASE_IMAGE=$base_os_image
--build-arg=OS_BASE_IMAGE=$base_os_image
--file=$dockerfile
$tags
$context
@ -257,7 +257,7 @@ jobs:
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION `
--label org.opencontainers.image.created=$Env:LABEL_CREATED `
--build-arg=BUILD_BASE_IMAGE=$base_os_image `
--build-arg=OS_BASE_IMAGE=$base_os_image `
--file=$dockerfile `
$tags `
$context
@ -717,7 +717,7 @@ jobs:
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION
--label org.opencontainers.image.created=$Env:LABEL_CREATED
--build-arg=BUILD_BASE_IMAGE=$base_build_image
--build-arg=BASE_IMAGE=$base_image
--build-arg=OS_BASE_IMAGE=$base_image
--file=$dockerfile
$tags
$context
@ -726,7 +726,7 @@ jobs:
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION `
--label org.opencontainers.image.created=$Env:LABEL_CREATED `
--build-arg=BUILD_BASE_IMAGE=$base_build_image `
--build-arg=BASE_IMAGE=$base_image `
--build-arg=OS_BASE_IMAGE=$base_image `
--file=$dockerfile `
$tags `
$context

View File

@ -1,14 +1,14 @@
# syntax=docker/dockerfile:1
# escape=`
ARG OS_BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.2
ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent-${ZBX_VERSION}
ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
FROM ${BUILD_BASE_IMAGE} AS builder
FROM ${BASE_IMAGE}
FROM ${OS_BASE_IMAGE}
ARG MAJOR_VERSION
ARG ZBX_VERSION

View File

@ -1,14 +1,13 @@
# syntax=docker/dockerfile:1
# escape=`
ARG OS_BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.2
ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent2-${ZBX_VERSION}
ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
FROM ${BUILD_BASE_IMAGE} AS builder
FROM ${BASE_IMAGE}
FROM ${OS_BASE_IMAGE}
ARG MAJOR_VERSION
ARG ZBX_VERSION

View File

@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1
# escape=`
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
FROM $BUILD_BASE_IMAGE as builder_base
ARG OS_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
FROM ${OS_BASE_IMAGE}
ARG PCRE2_VERSION=10.44
ARG OPENSSL_VERSION=3.3.2
@ -10,7 +10,6 @@ ARG ZLIB_VERSION=1.3.1
ARG CURL_VERSION=8.11.1
ARG BUILD_ARCH=x64
ARG CPU_MODEL=AMD64
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.2
@ -28,7 +27,7 @@ ARG ZLIB_URL=https://zlib.net/zlib-$ZLIB_VERSION.tar.gz
ARG CURL_URL=https://curl.se/download/curl-$CURL_VERSION.tar.gz
ENV ZBX_VERSION=$ZBX_VERSION `
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
BUILD_ARCH=$BUILD_ARCH `
GIT_URL=$GIT_URL PERL_URL=$PERL_URL NASM_URL=$NASM_URL `
VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL `
PCRE2_VERSION=$PCRE2_VERSION OPENSSL_VERSION=$OPENSSL_VERSION LIBMODBUS_VERSION=$LIBMODBUS_VERSION `

View File

@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1
# escape=`
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
FROM $BUILD_BASE_IMAGE as builder_base
ARG OS_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
FROM ${OS_BASE_IMAGE}
ARG PCRE2_VERSION=10.44
ARG OPENSSL_VERSION=3.3.2
@ -10,7 +10,6 @@ ARG GOLANG_VERSION=1.23.2
ARG MSYSTEM=UCRT64
ARG BUILD_ARCH=x64
ARG CPU_MODEL=AMD64
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.2
@ -24,7 +23,7 @@ ARG PCRE2_URL=https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE
ARG OPENSSL_URL=https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz
ENV ZBX_VERSION=$ZBX_VERSION `
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
BUILD_ARCH=$BUILD_ARCH `
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 `
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL `

View File

@ -1,188 +0,0 @@
# syntax=docker/dockerfile:1
# escape=`
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
FROM $BUILD_BASE_IMAGE as builder_base
ARG PCRE2_VERSION=10.44
ARG OPENSSL_VERSION=3.3.2
ARG GOLANG_VERSION=1.23.2
ARG MSYSTEM=CLANG64
ARG BUILD_ARCH=x64
ARG CPU_MODEL=AMD64
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/17/release/vs_buildtools.exe
ARG GOLANG_URL=https://go.dev/dl/go$GOLANG_VERSION.windows-amd64.zip
ARG MSYS2_URL=https://api.github.com/repos/msys2/msys2-installer/releases/latest
ARG PCRE2_URL=https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.zip
ARG OPENSSL_URL=https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz
ENV ZBX_VERSION=$ZBX_VERSION `
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
GOLANG_VERSION=$GOLANG_VERSION MSYS2_URL=$MSYS2_URL `
PCRE2_VERSION=$PCRE2_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL `
CHERE_INVOKING=yes MSYSTEM=$MSYSTEM
LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
org.opencontainers.image.vendor="Zabbix SIA" `
org.opencontainers.image.url="https://zabbix.com/" `
org.opencontainers.image.description="Zabbix build base image contains all required packages to build Zabbix agent 2 images" `
org.opencontainers.image.licenses="AGPL v3.0" `
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
org.opencontainers.image.version="${ZBX_VERSION}"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ADD --checksum=sha256:21c6f0523abfd37a2f5cc85879d0ff32723ab496347f0d20793df888ecec3957 $PCRE2_URL C:\pcre2.zip
ADD --checksum=sha256:2e8a40b01979afe8be0bbfb3de5dc1c6709fedb46d6c89c10da114ab5fc3d281 $OPENSSL_URL C:\openssl.tar.gz
RUN Set-Location -Path $env:SystemDrive\.; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
`
$env:PATH = $env:PATH + [string]::Format(';{0}\go\bin;{0}\msys64\usr\bin;{0}\msys64\{1}\bin', $env:SystemDrive, $env:MSYSTEM.ToLower()); `
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
`
$env:BUILD_OUTPUT = [string]::Format('{0}\build_output', $env:SystemDrive); `
[Environment]::SetEnvironmentVariable('BUILD_OUTPUT', $env:BUILD_OUTPUT, [EnvironmentVariableTarget]::Machine); `
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
[Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); `
`
Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); `
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'bc28fe3002cd65cec65d0e4f6000584dacb8c71bfaff8801dfb532855ca42513'; `
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ($d_sha256 -ne $sha256) { `
Write-Host ('Checksum Go Lang ({0}) failed!' -f $d_sha256); `
exit 1; `
}; `
`
Write-Host ('Downloading {0} ...' -f $env: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 $(Invoke-RestMethod -UseBasicParsing $env:MSYS2_URL | `
Select -ExpandProperty "assets" | `
Select -ExpandProperty "browser_download_url" | `
Select-String -Pattern '.sfx.exe$').ToString(); `
`
$sha256 = 'D96C53ECBFA4B9D81F6C58077965BB2E31472A8BDA4D4446EF8F45F9C601B11D'; `
$d_sha256 = (Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash -ne $sha256) { `
Write-Host ('Checksum MSYS2 ({0}) failed!' -f $d_sha256); `
# exit 1; `
}; `
`
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 MSYS2...'; `
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
bash -lc 'pacman --noprogressbar --sync --quiet --noconfirm mingw-w64-clang-x86_64-gcc-compat mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-make git'; `
bash -lc 'pacman --noprogressbar --noconfirm -Scc'; `
bash -lc 'rm -rf /usr/share/man/* /usr/share/doc/* /usr/share/locale/*'; `
bash -lc 'rm -rf /$MSYSTEM/usr/share/man/* /$MSYSTEM/usr/share/doc/* /$MSYSTEM/usr/share/locale/*'; `
bash -lc 'rm -rf /$MSYSTEM/share/man/* /$MSYSTEM/share/doc/* /$MSYSTEM/share/locale/*'; `
bash -lc 'rm -rf /var/cache/pacman/pkg/*'; `
taskkill /F /FI 'MODULES eq msys-2.0.dll' | Out-Null; `
compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; `
`
Write-Host 'Verifying install ("bash --version") ...'; `
bash --version; `
`
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
cmd /C start /w $env:TEMP\vs_buildtools.exe `
--quiet `
--wait `
--norestart `
--nocache `
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" `
--channelUri https://aka.ms/vs/17/release/channel `
--installChannelUri https://aka.ms/vs/17/release/channel `
--channelId VisualStudio.17.Release `
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64; `
if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { `
throw $err; `
}; `
Wait-Process -name msiexec; `
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
`
$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 'Removing downloaded...'; `
Remove-Item -Force -Recurse $env:TEMP\*; `
Write-Host 'Build environment is ready...'; `
`
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
`
New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; `
New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; `
Set-Location -Path $env:BUILD_SRC; `
`
Write-Host 'Extracting PCRE2 archive ...'; `
Expand-Archive -Path $env:SystemDrive\pcre2.zip -DestinationPath $env:BUILD_SRC; `
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:SystemDrive\openssl.tar.gz"; `
Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; `
`
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 `
-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 | Out-Null; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; `
Write-Host 'PCRE2 is ready...'; `
`
Write-Host 'Building OpenSSL library...'; `
Set-Location -Path $env:BUILD_SRC\openssl; `
perl Configure `
mingw64 `
no-shared `
no-ui-console `
no-tests `
no-unit-test `
no-capieng `
--api=1.1.0 `
--libdir=lib `
--prefix=$env:BUILD_OUTPUT/openssl `
--openssldir=$env:BUILD_OUTPUT/openssl_ssl; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" build_sw; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install_dev; `
mingw32-make -s clean | Out-Null; `
Write-Host 'OpenSSL is ready...'; `
`
Write-Host 'Removing downloaded...'; `
Remove-Item -Force -Recurse $env:TEMP\*;

View File

@ -1,206 +0,0 @@
# syntax=docker/dockerfile:1
# escape=`
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
FROM $BUILD_BASE_IMAGE as builder_base
ARG PCRE2_VERSION=10.44
ARG OPENSSL_VERSION=3.3.2
ARG GOLANG_VERSION=1.23.2
ARG MSYSTEM=MINGW64
ARG BUILD_ARCH=x64
ARG CPU_MODEL=AMD64
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG MINGW_URL=https://github.com/niXman/mingw-builds-binaries/releases/download/14.2.0-rt_v12-rev0/x86_64-14.2.0-release-win32-seh-msvcrt-rt_v12-rev0.7z
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/17/release/vs_buildtools.exe
ARG GOLANG_URL=https://go.dev/dl/go$GOLANG_VERSION.windows-amd64.zip
ARG MSYS2_URL=https://api.github.com/repos/msys2/msys2-installer/releases/latest
ARG PCRE2_URL=https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.zip
ARG OPENSSL_URL=https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz
ENV ZBX_VERSION=$ZBX_VERSION `
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
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 `
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL `
CHERE_INVOKING=yes MSYSTEM=$MSYSTEM
LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
org.opencontainers.image.vendor="Zabbix SIA" `
org.opencontainers.image.url="https://zabbix.com/" `
org.opencontainers.image.description="Zabbix build base image contains all required packages to build Zabbix agent 2 images" `
org.opencontainers.image.licenses="AGPL v3.0" `
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
org.opencontainers.image.version="${ZBX_VERSION}"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ADD --checksum=sha256:21c6f0523abfd37a2f5cc85879d0ff32723ab496347f0d20793df888ecec3957 $PCRE2_URL C:\pcre2.zip
ADD --checksum=sha256:2e8a40b01979afe8be0bbfb3de5dc1c6709fedb46d6c89c10da114ab5fc3d281 $OPENSSL_URL C:\openssl.tar.gz
RUN Set-Location -Path $env:SystemDrive\.; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
`
$env:PATH = $env:PATH + [string]::Format(';{0}\mingw64\bin;{0}\go\bin;{0}\msys64\usr\bin;{0}\msys64\{1}\bin', $env:SystemDrive, $env:MSYSTEM.ToLower()); `
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
`
$env:BUILD_OUTPUT = [string]::Format('{0}\build_output', $env:SystemDrive); `
[Environment]::SetEnvironmentVariable('BUILD_OUTPUT', $env:BUILD_OUTPUT, [EnvironmentVariableTarget]::Machine); `
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
[Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); `
`
Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); `
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'bc28fe3002cd65cec65d0e4f6000584dacb8c71bfaff8801dfb532855ca42513'; `
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ($d_sha256 -ne $sha256) { `
Write-Host ('Checksum Go Lang ({0}) failed!' -f $d_sha256); `
exit 1; `
}; `
`
Write-Host ('Downloading {0} ...' -f $env:MSYS2_URL); `
Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $(Invoke-RestMethod -UseBasicParsing $env:MSYS2_URL | `
Select -ExpandProperty "assets" | `
Select -ExpandProperty "browser_download_url" | `
Select-String -Pattern '.sfx.exe$').ToString(); `
`
$sha256 = 'D96C53ECBFA4B9D81F6C58077965BB2E31472A8BDA4D4446EF8F45F9C601B11D'; `
$d_sha256 = (Get-FileHash $env:TEMP\msys2.sfx.exe -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ($d_sha256 -ne $sha256) { `
Write-Host ('Checksum MSYS2 ({0}) failed!' -f $d_sha256); `
# exit 1; `
}; `
`
Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); `
Invoke-WebRequest -OutFile $env:TEMP\mingw.7z -Uri $env:MINGW_URL; `
`
$sha256 = '32bf3d1337c89f1f0326b42f49fea96fc7eb115af29b765a69bc69be546fd2a1'; `
$d_sha256 = (Get-FileHash $env:TEMP\mingw.7z -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ($d_sha256 -ne $sha256) { `
Write-Host ('Checksum Mingw-w64 ({0}) failed!' -f $d_sha256); `
exit 1; `
}; `
`
Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); `
Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; `
`
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 MSYS2...'; `
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
bash -lc 'pacman --noprogressbar --sync --quiet --noconfirm mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-7zip git'; `
bash -lc 'pacman --noprogressbar --noconfirm -Scc'; `
bash -lc 'rm -rf /usr/share/man/* /usr/share/doc/* /usr/share/locale/*'; `
bash -lc 'rm -rf /$MSYSTEM/usr/share/man/* /$MSYSTEM/usr/share/doc/* /$MSYSTEM/usr/share/locale/*'; `
bash -lc 'rm -rf /$MSYSTEM/share/man/* /$MSYSTEM/share/doc/* /$MSYSTEM/share/locale/*'; `
bash -lc 'rm -rf /var/cache/pacman/pkg/*'; `
taskkill /F /FI 'MODULES eq msys-2.0.dll' | Out-Null; `
compact /c /i /s:$env:SystemDrive\msys64 | Out-Null; `
`
Write-Host 'Verifying install ("bash --version") ...'; `
bash --version; `
`
Write-Host '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 ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
cmd /C start /w $env:TEMP\vs_buildtools.exe `
--quiet `
--wait `
--norestart `
--nocache `
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" `
--channelUri https://aka.ms/vs/17/release/channel `
--installChannelUri https://aka.ms/vs/17/release/channel `
--channelId VisualStudio.17.Release `
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64; `
if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { `
throw $err; `
}; `
Wait-Process -name msiexec; `
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
`
$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 'Removing downloaded...'; `
Remove-Item -Force -Recurse $env:TEMP\*; `
Write-Host 'Build environment is ready...'; `
`
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
`
New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; `
New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; `
Set-Location -Path $env:BUILD_SRC; `
`
Write-Host 'Extracting PCRE2 archive ...'; `
Expand-Archive -Path $env:SystemDrive\pcre2.zip -DestinationPath $env:BUILD_SRC; `
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:SystemDrive\openssl.tar.gz"; `
Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; `
`
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 `
-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 | Out-Null; `
Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; `
Write-Host 'PCRE2 is ready...'; `
`
Write-Host 'Building OpenSSL library...'; `
Set-Location -Path $env:BUILD_SRC\openssl; `
perl Configure `
mingw64 `
no-shared `
no-ui-console `
no-tests `
no-unit-test `
no-capieng `
--api=1.1.0 `
--libdir=lib `
--prefix=$env:BUILD_OUTPUT/openssl `
--openssldir=$env:BUILD_OUTPUT/openssl_ssl; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" build_sw; `
mingw32-make -s -j"""$env:NUMBER_OF_PROCESSORS""" install_dev; `
mingw32-make -s clean | Out-Null; `
Write-Host 'OpenSSL is ready...'; `
`
Write-Host 'Removing downloaded...'; `
Remove-Item -Force -Recurse $env:TEMP\*;

View File

@ -1,141 +0,0 @@
# syntax=docker/dockerfile:1
# escape=`
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
FROM $BUILD_BASE_IMAGE as builder_base
ARG GOLANG_VERSION=1.23.2
ARG BUILD_ARCH=x64
ARG CPU_MODEL=AMD64
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG GIT_URL=https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/MinGit-2.47.1-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/20241030/llvm-mingw-20241030-ucrt-x86_64.zip
ARG VCPKG_GIT=https://github.com/microsoft/vcpkg.git
ENV ZBX_VERSION=$ZBX_VERSION `
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
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>" `
org.opencontainers.image.vendor="Zabbix SIA" `
org.opencontainers.image.url="https://zabbix.com/" `
org.opencontainers.image.description="Zabbix build base image contains all required packages to build Zabbix agent 2 images" `
org.opencontainers.image.licenses="AGPL v3.0" `
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
org.opencontainers.image.version="${ZBX_VERSION}"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Set-Location -Path $env:SystemDrive\.; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
`
$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 = '7b26cc61866c5c0ec050797f57837bf064eacd3aaa87ae316e96c6936235cf29'; `
$d_sha256 = (Get-FileHash $env:TEMP\git.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
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_lang.zip -Uri $env:GOLANG_URL; `
`
$sha256 = 'bc28fe3002cd65cec65d0e4f6000584dacb8c71bfaff8801dfb532855ca42513'; `
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ($d_sha256 -ne $sha256) { `
Write-Host ('Checksum Go Lang ({0}) failed!' -f $d_sha256); `
exit 1; `
}; `
`
Write-Host ('Downloading {0} ...' -f $env:LLVM_MINGW); `
Invoke-WebRequest -OutFile $env:TEMP\llvm_mingw.zip -Uri $env:LLVM_MINGW; `
`
$sha256 = '7dd9884c976bb20bcbcda9077aa3dd2e857cfd073012f39668cdeddb285d93f8'; `
$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 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; `
`
Write-Host 'Installing GIT...'; `
Expand-Archive `
-Path $env:TEMP\git.zip `
-DestinationPath $env:SystemDrive\git\.; `
Write-Host 'Removing downloaded...'; `
`
Write-Host 'Verifying install ("git version") ...'; `
git version; `
`
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-20241030-ucrt-x86_64\ -Destination $env:SystemDrive\llvm_mingw; `
`
Write-Host 'Verifying install ("gcc -v") ...'; `
gcc -v; `
`
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
cmd /C start /w $env:TEMP\vs_buildtools.exe `
--quiet `
--wait `
--norestart `
--nocache `
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" `
--channelUri https://aka.ms/vs/17/release/channel `
--installChannelUri https://aka.ms/vs/17/release/channel `
--channelId VisualStudio.17.Release `
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64; `
if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { `
throw $err; `
}; `
Wait-Process -name msiexec; `
Write-Host ('{0} - Visual Studio components installed' -f $(Get-Date -format 'u')); `
`
$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 ...'; `
Remove-Item -Force -Recurse $env:TEMP\*; `
Write-Host 'Build environment is ready...';

View File

@ -4,7 +4,7 @@ ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.2
ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent-${ZBX_VERSION}
FROM ${BUILD_BASE_IMAGE} as builder
FROM ${BUILD_BASE_IMAGE} AS builder
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

View File

@ -4,7 +4,7 @@ ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.2
ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent2-${ZBX_VERSION}
FROM ${BUILD_BASE_IMAGE} as builder
FROM ${BUILD_BASE_IMAGE} AS builder
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

View File

@ -1,124 +0,0 @@
# syntax=docker/dockerfile:1
# escape=`
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.1
ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent2-${ZBX_VERSION}
FROM ${BUILD_BASE_IMAGE} as builder
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.1
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 MSSQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mssql.git
ARG EMBER_PLUS_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/ember-plus.git
ARG GIT_BRANCH
ARG ZBX_PLUGINS_VERSION=${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=${ZBX_PLUGINS_VERSION} `
POSTGRESQL_PLUGIN_SOURCES=$POSTGRESQL_PLUGIN_SOURCES POSTGRESQL_PLUGIN_VERSION=${ZBX_PLUGINS_VERSION} `
MSSQL_PLUGIN_SOURCES=$MSSQL_PLUGIN_SOURCES MSSQL_PLUGIN_VERSION=${ZBX_PLUGINS_VERSION} `
EMBER_PLUS_PLUGIN_SOURCES=$EMBER_PLUS_PLUGIN_SOURCES EMBER_PLUS_PLUGIN_VERSION=${ZBX_PLUGINS_VERSION} `
ZABBIX_VERSION_RC_NUM=$ZABBIX_VERSION_RC_NUM `
ZBX_SOURCES_DIR=C:\\zabbix-${ZBX_VERSION} ZBX_OUTPUT_DIR=C:\\zabbix-${ZBX_VERSION}-output
LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
org.opencontainers.image.vendor="Zabbix SIA" `
org.opencontainers.image.url="https://zabbix.com/" `
org.opencontainers.image.description="Zabbix build for agent 2 images based on Windows" `
org.opencontainers.image.licenses="AGPL v3.0" `
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
org.opencontainers.image.version="${ZBX_VERSION}" `
org.opencontainers.image.source="${ZBX_SOURCES}"
RUN Set-Location -Path $env:SystemDrive\.; `
`
New-Item -ItemType directory -Path $env:ZBX_SOURCES_DIR | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\sbin | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\conf | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\conf\zabbix_agentd.d | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\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:ZBX_SOURCES_DIR; `
`
Write-Host ('Building Zabbix {0} version ...' -f $env:ZBX_VERSION); `
Set-Location -Path $env:ZBX_SOURCES_DIR; `
$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:ZBX_SOURCES_DIR\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 `
OPENSSL=$env:BUILD_OUTPUT\openssl `
RFLAGS="""-DZABBIX_VERSION_RC_NUM=$env:ZABBIX_VERSION_RC_NUM"""; `
`
Write-Host 'Verifying build ("zabbix_agent2.exe -V") ...'; `
& $env:ZBX_SOURCES_DIR\bin\win64\zabbix_agent2.exe -V; `
dumpbin /dependents $env:ZBX_SOURCES_DIR\bin\win64\zabbix_agent2.exe; `
`
Copy-Item -Path $env:ZBX_SOURCES_DIR\bin\win64\zabbix_agent2.exe $env:ZBX_OUTPUT_DIR\sbin; `
Copy-Item -Path $env:ZBX_SOURCES_DIR\src\go\conf\zabbix_agent2.win.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.conf; `
Copy-Item -Recurse -Path $env:ZBX_SOURCES_DIR\src\go\conf\zabbix_agent2.d $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d; `
mingw32-make -s clean; `
`
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-$env:MONGODB_PLUGIN_VERSION; `
Set-Location -Path $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION; `
mingw32-make; `
`
Write-Host 'Verifying MongoDB plugin ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
& $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION\zabbix-agent2-plugin-mongodb.exe -V; `
`
Copy-Item -Path $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION\zabbix-agent2-plugin-mongodb.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\mongodb.exe; `
Copy-Item -Path $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION\mongodb.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.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-$env:POSTGRESQL_PLUGIN_VERSION; `
Set-Location -Path $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION; `
mingw32-make; `
`
Write-Host 'Verifying build ("zabbix-agent2-plugin-postgresql.exe -V") ...'; `
& $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION\zabbix-agent2-plugin-postgresql.exe -V; `
`
Copy-Item -Path $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION\zabbix-agent2-plugin-postgresql.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\postgresql.exe; `
Copy-Item -Path $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION\postgresql.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.d; `
mingw32-make -s clean; `
`
Write-Host ('Building Zabbix MSSQL plugin {0} version ...' -f $env:MSSQL_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:MSSQL_PLUGIN_SOURCES --branch $env:MSSQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION; `
Set-Location -Path $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION; `
mingw32-make; `
`
Write-Host 'Verifying MSSQL plugin ("zabbix-agent2-plugin-mssql.exe -V") ...'; `
& $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION\zabbix-agent2-plugin-mssql.exe -V; `
`
Copy-Item -Path $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION\zabbix-agent2-plugin-mssql.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\mssql.exe; `
Copy-Item -Path $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION\mssql.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.d; `
mingw32-make -s clean; `
`
Write-Host ('Building Zabbix Ember+ plugin {0} version ...' -f $env:EMBER_PLUS_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:EMBER_PLUS_PLUGIN_SOURCES --branch $env:EMBER_PLUS_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION; `
Set-Location -Path $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION; `
mingw32-make; `
`
Write-Host 'Verifying Ember+ plugin ("zabbix-agent2-plugin-ember-plus.exe -V") ...'; `
& $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION\zabbix-agent2-plugin-ember-plus.exe -V; `
`
Copy-Item -Path $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION\zabbix-agent2-plugin-ember-plus.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\ember-plus.exe; `
Copy-Item -Path $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION\ember.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.d; `
mingw32-make -s clean; `
Write-Host 'Zabbix binaries are compiled...';

View File

@ -1,125 +0,0 @@
# syntax=docker/dockerfile:1
# escape=`
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.1
ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent2-${ZBX_VERSION}
FROM ${BUILD_BASE_IMAGE} as builder
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ARG MAJOR_VERSION=7.2
ARG ZBX_VERSION=${MAJOR_VERSION}.1
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 MSSQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mssql.git
ARG EMBER_PLUS_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/ember-plus.git
ARG GIT_BRANCH
ARG ZBX_PLUGINS_VERSION=${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=${ZBX_PLUGINS_VERSION} `
POSTGRESQL_PLUGIN_SOURCES=$POSTGRESQL_PLUGIN_SOURCES POSTGRESQL_PLUGIN_VERSION=${ZBX_PLUGINS_VERSION} `
MSSQL_PLUGIN_SOURCES=$MSSQL_PLUGIN_SOURCES MSSQL_PLUGIN_VERSION=${ZBX_PLUGINS_VERSION} `
EMBER_PLUS_PLUGIN_SOURCES=$EMBER_PLUS_PLUGIN_SOURCES EMBER_PLUS_PLUGIN_VERSION=${ZBX_PLUGINS_VERSION} `
ZABBIX_VERSION_RC_NUM=$ZABBIX_VERSION_RC_NUM `
ZBX_SOURCES_DIR=C:\\zabbix-${ZBX_VERSION} ZBX_OUTPUT_DIR=C:\\zabbix-${ZBX_VERSION}-output
LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
org.opencontainers.image.vendor="Zabbix SIA" `
org.opencontainers.image.url="https://zabbix.com/" `
org.opencontainers.image.description="Zabbix build for agent 2 images based on Windows" `
org.opencontainers.image.licenses="AGPL v3.0" `
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
org.opencontainers.image.version="${ZBX_VERSION}" `
org.opencontainers.image.source="${ZBX_SOURCES}"
RUN Set-Location -Path $env:SystemDrive\.; `
`
New-Item -ItemType directory -Path $env:ZBX_SOURCES_DIR | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\sbin | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\conf | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\conf\zabbix_agentd.d | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\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:ZBX_SOURCES_DIR; `
`
Write-Host ('Building Zabbix {0} version ...' -f $env:ZBX_VERSION); `
Set-Location -Path $env:ZBX_SOURCES_DIR; `
$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:ZBX_SOURCES_DIR\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 `
OPENSSL=$env:SystemDrive\vcpkg\installed\x64-mingw-static-release `
RFLAGS="""-DZABBIX_VERSION_RC_NUM=$env:ZABBIX_VERSION_RC_NUM"""; `
`
Write-Host 'Verifying build ("zabbix_agent2.exe -V") ...'; `
& $env:ZBX_SOURCES_DIR\bin\win64\zabbix_agent2.exe -V; `
dumpbin /dependents $env:ZBX_SOURCES_DIR\bin\win64\zabbix_agent2.exe; `
`
Copy-Item -Path $env:ZBX_SOURCES_DIR\bin\win64\zabbix_agent2.exe $env:ZBX_OUTPUT_DIR\sbin; `
Copy-Item -Path $env:ZBX_SOURCES_DIR\src\go\conf\zabbix_agent2.win.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.conf; `
Copy-Item -Recurse -Path $env:ZBX_SOURCES_DIR\src\go\conf\zabbix_agent2.d $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d; `
mingw32-make -s clean; `
`
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-$env:MONGODB_PLUGIN_VERSION; `
Set-Location -Path $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION; `
mingw32-make; `
`
Write-Host 'Verifying MongoDB plugin ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
& $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION\zabbix-agent2-plugin-mongodb.exe -V; `
`
Copy-Item -Path $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION\zabbix-agent2-plugin-mongodb.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\mongodb.exe; `
Copy-Item -Path $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION\mongodb.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.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-$env:POSTGRESQL_PLUGIN_VERSION; `
Set-Location -Path $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION; `
mingw32-make; `
`
Write-Host 'Verifying build ("zabbix-agent2-plugin-postgresql.exe -V") ...'; `
& $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION\zabbix-agent2-plugin-postgresql.exe -V; `
`
Copy-Item -Path $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION\zabbix-agent2-plugin-postgresql.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\postgresql.exe; `
Copy-Item -Path $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION\postgresql.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.d; `
mingw32-make -s clean; `
`
Write-Host ('Building Zabbix MSSQL plugin {0} version ...' -f $env:MSSQL_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:MSSQL_PLUGIN_SOURCES --branch $env:MSSQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION; `
Set-Location -Path $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION; `
mingw32-make; `
`
Write-Host 'Verifying MSSQL plugin ("zabbix-agent2-plugin-mssql.exe -V") ...'; `
& $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION\zabbix-agent2-plugin-mssql.exe -V; `
`
Copy-Item -Path $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION\zabbix-agent2-plugin-mssql.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\mssql.exe; `
Copy-Item -Path $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION\mssql.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.d; `
mingw32-make -s clean; `
`
Write-Host ('Building Zabbix Ember+ plugin {0} version ...' -f $env:EMBER_PLUS_PLUGIN_VERSION); `
git -c advice.detachedHead=false clone $env:EMBER_PLUS_PLUGIN_SOURCES --branch $env:EMBER_PLUS_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION; `
Set-Location -Path $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION; `
mingw32-make; `
`
Write-Host 'Verifying Ember+ plugin ("zabbix-agent2-plugin-ember-plus.exe -V") ...'; `
& $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION\zabbix-agent2-plugin-ember-plus.exe -V; `
`
Copy-Item -Path $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION\zabbix-agent2-plugin-ember-plus.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\ember-plus.exe; `
Copy-Item -Path $env:SystemDrive\ember-plus-plugin-$env:EMBER_PLUS_PLUGIN_VERSION\ember.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.d; `
mingw32-make -s clean; `
Write-Host 'Zabbix binaries are compiled...';