diff --git a/Dockerfiles/agent/windows/Dockerfile b/Dockerfiles/agent/windows/Dockerfile index 6f598acf5..debb387db 100644 --- a/Dockerfiles/agent/windows/Dockerfile +++ b/Dockerfiles/agent/windows/Dockerfile @@ -68,4 +68,6 @@ USER zabbix EXPOSE 10050/tcp -CMD C:\zabbix\docker-entrypoint.ps1 C:\zabbix\sbin\zabbix_agentd.exe -c C:\zabbix\conf\zabbix_agentd.conf -f +ENTRYPOINT ["pwsh", "-File", "C:\\zabbix\\docker-entrypoint.ps1"] + +CMD ["C:\\zabbix\\sbin\\zabbix_agentd.exe", "-c", "C:\\zabbix\\conf\\zabbix_agentd.conf", "-f"] diff --git a/Dockerfiles/agent2/windows/Dockerfile b/Dockerfiles/agent2/windows/Dockerfile index 7a9c67dd3..d3b447555 100644 --- a/Dockerfiles/agent2/windows/Dockerfile +++ b/Dockerfiles/agent2/windows/Dockerfile @@ -71,4 +71,6 @@ 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.conf -f +ENTRYPOINT ["pwsh", "-File", "C:\\zabbix\\docker-entrypoint.ps1"] + +CMD ["C:\\zabbix\\sbin\\zabbix_agent2.exe", "-c", "C:\\zabbix\\conf\\zabbix_agent2.conf", "-f"] diff --git a/Dockerfiles/build-base/windows/Dockerfile.agent2 b/Dockerfiles/build-base/windows/Dockerfile.agent2 index 7c3ecf7bc..8f36dd120 100644 --- a/Dockerfiles/build-base/windows/Dockerfile.agent2 +++ b/Dockerfiles/build-base/windows/Dockerfile.agent2 @@ -5,7 +5,7 @@ ARG OS_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022 ARG PCRE2_VERSION=10.47 ARG OPENSSL_VERSION=3.5.4 ARG GOLANG_VERSION=1.26.2 -ARG PWSH_VERSION=7.5.4 +ARG PWSH_VERSION=7.6.1 ARG MSYSTEM=UCRT64 @@ -30,7 +30,7 @@ ARG OPENSSL_URL=https://github.com/openssl/openssl/releases/download/openssl-$OP ARG PWSH_URL=https://github.com/PowerShell/PowerShell/releases/download/v$PWSH_VERSION/PowerShell-$PWSH_VERSION-win-x64.zip -ADD --checksum=sha256:b40d192ae95ba6ccc4cc362ff4e1b18ca6fb5055bebbcd3920684e12701fa8f6 $PWSH_URL build_deps\pwsh.zip +ADD --checksum=sha256:B5C9E8457CA7DF4998ABE3CC2C58E6DD4005AD1B4C5320BBAC86244A747DB91D $PWSH_URL build_deps\pwsh.zip ADD --checksum=sha256:98eb3570bade15cb826b0909338df6cc6d2cf590bc39c471142002db3832b708 $GOLANG_URL build_deps\go_lang.zip ADD --checksum=sha256:9e9f0b912a59d2cfb3ce5a01bae4e7a05e4be4f8ff89e36e0f57606ec525525d $MINGW_URL build_deps\mingw.7z ADD --checksum=sha256:99f2fee9a7b1c344600ac97347e7be23a1f802d8d843b339ec7473a8ed8d49a6 $MSYS2_URL build_deps\msys2.sfx.exe @@ -44,8 +44,10 @@ RUN $env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); ` [Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); ` $env:BUILD_DEPS = [string]::Format('{0}\build_deps', $env:SystemDrive); ` [Environment]::SetEnvironmentVariable('BUILD_DEPS', $env:BUILD_DEPS, [EnvironmentVariableTarget]::Machine); ` + $env:MSYS_BIN = [string]::Format('{0}\msys64\{1}\bin', $env:BUILD_DEPS, $env:MSYSTEM.ToLower()); ` + [Environment]::SetEnvironmentVariable('MSYS_BIN', $env:MSYS_BIN, [EnvironmentVariableTarget]::Machine); ` ` - $env:PATH = $env:PATH + [string]::Format(';{0}\mingw64\bin;{0}\go\bin;{0}\msys64\usr\bin;{0}\msys64\{1}\bin', $env:BUILD_DEPS, $env:MSYSTEM.ToLower()); ` + $env:PATH = $env:PATH + [string]::Format(';{0}\mingw64\bin;{0}\go\bin;{0}\msys64\usr\bin', $env:BUILD_DEPS); ` [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); ` ` Set-Location -Path $env:BUILD_DEPS; ` @@ -61,19 +63,21 @@ RUN $env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); ` ` Write-Host 'Installing MSYS2...'; ` & $env:BUILD_DEPS\msys2.sfx.exe -y -o"""$env:BUILD_DEPS\""" | Out-Null; ` - bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; ` - bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; ` - bash -lc 'pacman --noprogressbar --sync --quiet --noconfirm mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-make mingw-w64-ucrt-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/*'; ` + function msys() { bash @('-lc') + @Args; }; ` + msys """sed -i -E '/^\[(clangarm64|mingw32|mingw64|clang64)\]/,/^Include/ s/^[^#]/#&/' /etc/pacman.conf"""; ` + msys 'pacman --noprogressbar --noconfirm -Syuu'; ` + msys 'pacman --noprogressbar --noconfirm -Syuu'; ` + msys 'pacman --noprogressbar --sync --quiet --noconfirm mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-7zip git'; ` + msys 'pacman --noprogressbar --noconfirm -Scc'; ` + msys 'rm -rf /usr/share/man/* /usr/share/doc/* /usr/share/locale/*'; ` + msys 'rm -rf /$MSYSTEM/usr/share/man/* /$MSYSTEM/usr/share/doc/* /$MSYSTEM/usr/share/locale/*'; ` + msys 'rm -rf /$MSYSTEM/share/man/* /$MSYSTEM/share/doc/* /$MSYSTEM/share/locale/*'; ` + msys 'rm -rf /var/cache/pacman/pkg/*'; ` taskkill /F /FI 'MODULES eq msys-2.0.dll' | Out-Null; ` compact /c /i /s:$env:BUILD_DEPS\msys64 | Out-Null; ` ` Write-Host 'Installing Mingw-w64...'; ` - 7z x $env:BUILD_DEPS\mingw.7z; ` + & $env:MSYS_BIN\7z.exe x $env:BUILD_DEPS\mingw.7z -bso0 -bsp0; ` compact /c /i /s:$env:BUILD_DEPS\mingw64 | Out-Null; ` ` Write-Host 'Installing Go Lang...'; ` @@ -136,8 +140,10 @@ RUN Set-Location -Path $env:SystemDrive\.; ` [Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); ` $env:BUILD_DEPS = [string]::Format('{0}\build_deps', $env:SystemDrive); ` [Environment]::SetEnvironmentVariable('BUILD_DEPS', $env:BUILD_DEPS, [EnvironmentVariableTarget]::Machine); ` + $env:MSYS_BIN = [string]::Format('{0}\msys64\{1}\bin', $env:BUILD_DEPS, $env:MSYSTEM.ToLower()); ` + [Environment]::SetEnvironmentVariable('MSYS_BIN', $env:MSYS_BIN, [EnvironmentVariableTarget]::Machine); ` ` - $env:PATH = $env:PATH + [string]::Format(';{0}\mingw64\bin;{0}\go\bin;{0}\msys64\usr\bin;{0}\msys64\{1}\bin', $env:BUILD_DEPS, $env:MSYSTEM.ToLower()); ` + $env:PATH = $env:PATH + [string]::Format(';{0}\mingw64\bin;{0}\go\bin;{0}\msys64\usr\bin', $env:BUILD_DEPS); ` [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); ` ` New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; ` @@ -151,11 +157,14 @@ RUN Set-Location -Path $env:SystemDrive\.; ` Write-Host 'Verifying install ("gcc -v") ...'; ` gcc -v; ` ` + Write-Host 'Verifying install ("git -v") ...'; ` + git --version; ` + ` Write-Host 'Build environment is ready...'; RUN Write-Host 'Building PCRE2 library ...'; ` Set-Location -Path $env:BUILD_SRC\pcre2; ` - cmake -S $env:BUILD_SRC\pcre2 -B $env:BUILD_SRC\pcre2\build ` + & $env:MSYS_BIN\cmake.exe -S $env:BUILD_SRC\pcre2 -B $env:BUILD_SRC\pcre2\build ` -G 'MinGW Makefiles' ` -DBUILD_SHARED_LIBS=OFF ` -DBUILD_STATIC_LIBS=ON ` @@ -164,7 +173,7 @@ RUN Write-Host 'Building PCRE2 library ...'; ` -DPCRE2_BUILD_PCRE2GREP=OFF ` -DPCRE2_SUPPORT_JIT=OFF ` -DINSTALL_MSVC_PDB=OFF ` - -DCMAKE_C_COMPILER=gcc ` + -DCMAKE_C_COMPILER="""$env:BUILD_DEPS\mingw64\bin\gcc.exe""" ` -DCMAKE_C_FLAGS='-O2 -g' ` -DCMAKE_INSTALL_PREFIX="""$env:BUILD_OUTPUT\pcre2""" . ; ` Set-Location -Path $env:BUILD_SRC\pcre2\build; ` @@ -176,6 +185,7 @@ RUN Write-Host 'Building PCRE2 library ...'; ` RUN Write-Host 'Building OpenSSL library...'; ` Set-Location -Path $env:BUILD_SRC\openssl; ` + $env:CFLAGS = """$env:CFLAGS -Wno-overflow""".Trim(); ` perl Configure ` mingw64 ` no-capieng ` diff --git a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 index da8bded50..adac17d50 100644 --- a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 +++ b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 @@ -70,53 +70,47 @@ RUN Set-Location -Path $env:SystemDrive\.; ` 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; ` + mingw32-make -s clean; + +RUN function Build-Plugin { ` + param( ` + [Parameter(Mandatory)] [string] $Name, ` + [Parameter(Mandatory)] [string] $Repo, ` + [Parameter(Mandatory)] [string] $Version, ` + [Parameter(Mandatory)] [string] $Binary, ` + [Parameter(Mandatory)] [string] $Conf, ` + [Parameter(Mandatory)] [string] $OutName ` + ); ` + ` + $workDir = Join-Path $env:SystemDrive "$Name-plugin-$Version"; ` + $outBinDir = Join-Path $env:ZBX_OUTPUT_DIR 'zabbix-agent2-plugin'; ` + $outConfDir = Join-Path $env:ZBX_OUTPUT_DIR 'conf\zabbix_agent2.d\plugins.d'; ` + $binaryPath = Join-Path $workDir """$Binary.exe"""; ` + ` + Remove-Item -Recurse -Force $workDir -ErrorAction SilentlyContinue; ` + ` + Write-Host ('Building {0} plugin {1} version ...' -f $Name, $Version); ` + git -c advice.detachedHead=false clone $Repo --branch $Version --depth 1 --single-branch $workDir; ` + ` + Set-Location -Path $workDir; ` + mingw32-make; ` + ` + Write-Host ('Verifying {0} plugin ({1}.exe -V) ...' -f $Name, $Binary); ` + & $binaryPath -V; ` + ` + Copy-Item -Path $binaryPath -Destination (Join-Path $outBinDir """$OutName.exe""") -Force; ` + Copy-Item -Path (Join-Path $workDir $Conf) -Destination $outConfDir -Force; ` + ` + 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; ` + New-Item -ItemType Directory -Force -Path (Join-Path $env:ZBX_OUTPUT_DIR 'zabbix-agent2-plugin') | Out-Null; ` + New-Item -ItemType Directory -Force -Path (Join-Path $env:ZBX_OUTPUT_DIR 'conf\zabbix_agent2.d\plugins.d') | Out-Null; ` ` - 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...'; + Build-Plugin mongodb $env:MONGODB_PLUGIN_SOURCES $env:MONGODB_PLUGIN_VERSION zabbix-agent2-plugin-mongodb mongodb.conf mongodb; ` + Build-Plugin postgresql $env:POSTGRESQL_PLUGIN_SOURCES $env:POSTGRESQL_PLUGIN_VERSION zabbix-agent2-plugin-postgresql postgresql.conf postgresql; ` + Build-Plugin mssql $env:MSSQL_PLUGIN_SOURCES $env:MSSQL_PLUGIN_VERSION zabbix-agent2-plugin-mssql mssql.conf mssql; ` + $env:PATH = $env:PATH + [string]::Format(';{0}', $env:MSYS_BIN); ` + Build-Plugin ember $env:EMBER_PLUS_PLUGIN_SOURCES $env:EMBER_PLUS_PLUGIN_VERSION zabbix-agent2-plugin-ember-plus ember.conf ember-plus; ` + Build-Plugin nvidia-gpu $env:NVIDIA_GPU_PLUGIN_SOURCES $env:NVIDIA_GPU_PLUGIN_VERSION zabbix-agent2-plugin-nvidia-gpu nvidia.conf nvidia-gpu; +