Fixed minor issues with Windows containers

This commit is contained in:
Alexey Pustovalov 2025-01-11 18:32:46 +09:00
parent 85b1638f71
commit 5dd6f26f30
9 changed files with 244 additions and 156 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,19 +1,24 @@
# syntax=docker/dockerfile:1
# escape=`
ARG OS_BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}.8
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
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
ENV ZABBIX_USER_HOME_DIR="C:\zabbix" `
ZABBIX_CONF_DIR="C:\zabbix\conf"
ENV ZBX_USERPARAMETERDIR="${ZABBIX_USER_HOME_DIR}\user_scripts"
LABEL org.opencontainers.image.title="Zabbix agent" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
org.opencontainers.image.vendor="Zabbix SIA" `
@ -36,25 +41,25 @@ USER ContainerAdministrator
RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemDrive) + $env:PATH; `
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
`
$env:ZBX_HOME = [string]::Format('{0}\zabbix', $env:SystemDrive); `
[Environment]::SetEnvironmentVariable('ZBX_HOME', $env:ZBX_HOME, [EnvironmentVariableTarget]::Machine); `
[Environment]::SetEnvironmentVariable('ZABBIX_USER_HOME_DIR', $env:ZABBIX_USER_HOME_DIR, [EnvironmentVariableTarget]::Machine); `
`
Write-Host ('Verifying Zabbix agent {0} ...' -f $env:ZBX_VERSION); `
zabbix_agentd.exe -V;
RUN Set-Location -Path $env:SystemDrive\.; `
`
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\conf\zabbix_agentd.d | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\enc | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\modules | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\buffer | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_CONF_DIR | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_CONF_DIR\zabbix_agentd.d | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\enc | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\enc_internal | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_USERPARAMETERDIR | Out-Null; `
`
net accounts /MaxPWAge:unlimited; `
net user /add zabbix /expire:never /passwordreq:no; `
$acl = Get-Acl -Path $env:ZBX_HOME; `
$acl = Get-Acl -Path $env:ZABBIX_USER_HOME_DIR; `
$ace = New-Object Security.AccessControl.FileSystemAccessRule ('zabbix', 'Modify', 'ContainerInherit, ObjectInherit', 'InheritOnly', 'Allow'); `
$acl.AddAccessRule($ace); `
Set-Acl -AclObject $acl -Path $env:ZBX_HOME;
Set-Acl -AclObject $acl -Path $env:ZABBIX_USER_HOME_DIR;
USER zabbix

View File

@ -4,7 +4,6 @@ if ($env:DEBUG_MODE -eq "true") {
Set-PSDebug -trace 1
}
# Default Zabbix installation name
# Default Zabbix server host
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_HOST)) {
$env:ZBX_SERVER_HOST="zabbix-server"
@ -14,12 +13,9 @@ if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_PORT)) {
$env:ZBX_SERVER_PORT="10051"
}
# Default directories
# User 'zabbix' home directory
$ZabbixUserHomeDir="C:\zabbix"
# Configuration files directory
$ZabbixConfigDir="C:\zabbix\conf"
# Internal directory for TLS related files, used when TLS*File specified as plain text values
$ZabbixInternalEncDir="$env:ZABBIX_USER_HOME_DIR/enc_internal"
function Update-Config-Var {
Param (
@ -66,7 +62,7 @@ function Update-Config-Var {
}
if ($VarName -match '^TLS.*File$') {
$VarValue="$ZabbixUserHomeDir\enc\$VarValue"
$VarValue="$env:ZABBIX_USER_HOME_DIR\enc\$VarValue"
}
if ((Get-Content $ConfigPath | %{$_ -match "^$VarName="}) -contains $true -And $IsMultiple -ne $true) {
@ -119,35 +115,59 @@ function Update-Config-Multiple-Var {
}
}
function File-Process-From-Env {
Param (
[Parameter(Mandatory=$true, Position=0)]
[ValidateNotNullOrEmpty()]
[string] $ZbxAgentConfig,
[Parameter(Mandatory=$true, Position=1)]
[ValidateNotNullOrEmpty()]
[string] $VarName,
[Parameter(Mandatory=$false, Position=2)]
[string]$FileName = $null,
[Parameter(Mandatory=$false, Position=3)]
[string]$VarValue = $null
)
if (![string]::IsNullOrEmpty($VarValue)) {
$VarValue | Set-Content "$ZabbixInternalEncDir\$VarName"
$FileName="$ZabbixInternalEncDir\$VarName"
}
Update-Config-Var $ZbxAgentConfig "$VarName" "$FileName"
}
function Prepare-Zbx-Agent-Config {
Write-Host "** Preparing Zabbix agent configuration file"
$ZbxAgentConfig="$ZabbixConfigDir\zabbix_agentd.conf"
$ZbxAgentConfig="$env:ZABBIX_CONF_DIR\zabbix_agentd.conf"
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVESERVERS)) {
if ($env:ZBX_PASSIVESERVERS -eq $null) {
$env:ZBX_PASSIVESERVERS=""
}
else {
$env:ZBX_PASSIVESERVERS=",$env:ZBX_PASSIVESERVERS"
}
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST + $env:ZBX_PASSIVESERVERS
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVESERVERS)) {
if ($env:ZBX_ACTIVESERVERS -eq $null) {
$env:ZBX_ACTIVESERVERS=""
}
else {
$env:ZBX_ACTIVESERVERS=",$env:ZBX_ACTIVESERVERS"
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST) -And ![string]::IsNullOrEmpty($env:ZBX_PASSIVESERVERS)) {
$env:ZBX_PASSIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_PASSIVESERVERS"
}
elseif (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST
}
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST + ":" + $env:ZBX_SERVER_PORT + $env:ZBX_ACTIVESERVERS
Update-Config-Var $ZbxAgentConfig "LogType" "console"
Update-Config-Var $ZbxAgentConfig "LogFile"
Update-Config-Var $ZbxAgentConfig "LogFileSize"
Update-Config-Var $ZbxAgentConfig "DebugLevel" "$env:ZBX_DEBUGLEVEL"
Update-Config-Var $ZbxAgentConfig "SourceIP"
Update-Config-Var $ZbxAgentConfig "LogRemoteCommands" "$env:ZBX_LOGREMOTECOMMANDS"
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_PORT) -And $env:ZBX_SERVER_PORT -ne "10051") {
$env:ZBX_SERVER_HOST="$env:ZBX_SERVER_HOST:$env:ZBX_SERVER_PORT"
}
if (![string]::IsNullOrEmpty($env:ZBX_ACTIVESERVERS)) {
$env:ZBX_ACTIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_ACTIVESERVERS"
}
else {
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST
}
}
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVE_ALLOW)) {
$env:ZBX_PASSIVE_ALLOW="true"
@ -161,10 +181,6 @@ function Prepare-Zbx-Agent-Config {
Update-Config-Var $ZbxAgentConfig "Server"
}
Update-Config-Var $ZbxAgentConfig "ListenPort" "$env:ZBX_LISTENPORT"
Update-Config-Var $ZbxAgentConfig "ListenIP" "$env:ZBX_LISTENIP"
Update-Config-Var $ZbxAgentConfig "StartAgents" "$env:ZBX_STARTAGENTS"
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVE_ALLOW)) {
$env:ZBX_ACTIVE_ALLOW="true"
}
@ -176,6 +192,18 @@ function Prepare-Zbx-Agent-Config {
else {
Update-Config-Var $ZbxAgentConfig "ServerActive"
}
Update-Config-Var $ZbxAgentConfig "LogType" "console"
Update-Config-Var $ZbxAgentConfig "LogFile"
Update-Config-Var $ZbxAgentConfig "LogFileSize"
Update-Config-Var $ZbxAgentConfig "DebugLevel" "$env:ZBX_DEBUGLEVEL"
Update-Config-Var $ZbxAgentConfig "SourceIP"
Update-Config-Var $ZbxAgentConfig "LogRemoteCommands" "$env:ZBX_LOGREMOTECOMMANDS"
Update-Config-Var $ZbxAgentConfig "ListenPort" "$env:ZBX_LISTENPORT"
Update-Config-Var $ZbxAgentConfig "ListenIP" "$env:ZBX_LISTENIP"
Update-Config-Var $ZbxAgentConfig "StartAgents" "$env:ZBX_STARTAGENTS"
Update-Config-Var $ZbxAgentConfig "HeartbeatFrequency" "$env:ZBX_HEARTBEAT_FREQUENCY"
Update-Config-Var $ZbxAgentConfig "HostInterface" "$env:ZBX_HOSTINTERFACE"
@ -194,34 +222,45 @@ function Prepare-Zbx-Agent-Config {
# Please use include to enable Perfcounter feature
# update_config_multiple_var $ZBX_AGENT_CONFIG "PerfCounter" $env:ZBX_PERFCOUNTER
Update-Config-Var $ZbxAgentConfig "Timeout" "$env:ZBX_TIMEOUT"
Update-Config-Var $ZbxAgentConfig "Include" "$ZabbixConfigDir\zabbix_agentd.d\*.conf"
Update-Config-Var $ZbxAgentConfig "Include" "$env:ZABBIX_CONF_DIR\zabbix_agentd.d\*.conf"
Update-Config-Var $ZbxAgentConfig "UnsafeUserParameters" "$env:ZBX_UNSAFEUSERPARAMETERS"
Update-Config-Var $ZbxAgentConfig "UserParameterDir" "$ZabbixUserHomeDir\user_scripts\"
Update-Config-Var $ZbxAgentConfig "UserParameterDir" "$env:ZBX_USERPARAMETERDIR"
Update-Config-Var $ZbxAgentConfig "TLSConnect" "$env:ZBX_TLSCONNECT"
Update-Config-Var $ZbxAgentConfig "TLSAccept" "$env:ZBX_TLSACCEPT"
Update-Config-Var $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE"
Update-Config-Var $ZbxAgentConfig "TLSCRLFile" "$env:ZBX_TLSCRLFILE"
File-Process-From-Env $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE" "$env:ZBX_TLSCA"
File-Process-From-Env $ZbxAgentConfig "TLSCRLFile" "$env:ZBX_TLSCRLFILE" "$env:ZBX_TLSCRL"
Update-Config-Var $ZbxAgentConfig "TLSServerCertIssuer" "$env:ZBX_TLSSERVERCERTISSUER"
Update-Config-Var $ZbxAgentConfig "TLSServerCertSubject" "$env:ZBX_TLSSERVERCERTSUBJECT"
Update-Config-Var $ZbxAgentConfig "TLSCertFile" "$env:ZBX_TLSCERTFILE"
File-Process-From-Env $ZbxAgentConfig "TLSCertFile" "$env:ZBX_TLSCERTFILE" "$env:ZBX_TLSCERT"
Update-Config-Var $ZbxAgentConfig "TLSCipherAll" "$env:ZBX_TLSCIPHERALL"
Update-Config-Var $ZbxAgentConfig "TLSCipherAll13" "$env:ZBX_TLSCIPHERALL13"
Update-Config-Var $ZbxAgentConfig "TLSCipherCert" "$env:ZBX_TLSCIPHERCERT"
Update-Config-Var $ZbxAgentConfig "TLSCipherCert13" "$env:ZBX_TLSCIPHERCERT13"
Update-Config-Var $ZbxAgentConfig "TLSCipherPSK" "$env:ZBX_TLSCIPHERPSK"
Update-Config-Var $ZbxAgentConfig "TLSCipherPSK13" "$env:ZBX_TLSCIPHERPSK13"
Update-Config-Var $ZbxAgentConfig "TLSKeyFile" "$env:ZBX_TLSKEYFILE"
File-Process-From-Env $ZbxAgentConfig "TLSKeyFile" "$env:ZBX_TLSKEYFILE" "$env:ZBX_TLSKEY"
Update-Config-Var $ZbxAgentConfig "TLSPSKIdentity" "$env:ZBX_TLSPSKIDENTITY"
Update-Config-Var $ZbxAgentConfig "TLSPSKFile" "$env:ZBX_TLSPSKFILE"
File-Process-From-Env $ZbxAgentConfig "TLSPSKFile" "$env:ZBX_TLSPSKFILE" "$env:ZBX_TLSPSK"
Update-Config-Multiple-Var $ZbxAgentConfig "DenyKey" "$env:ZBX_DENYKEY"
Update-Config-Multiple-Var $ZbxAgentConfig "AllowKey" "$env:ZBX_ALLOWKEY"
}
function ClearZbxEnv() {
if ([string]::IsNullOrWhitespace($env:ZBX_CLEAR_ENV)) {
return
}
$env_vars=Get-ChildItem env:* | Where-Object {$_.Name -match "^ZBX_.*" } | foreach { $_.Name }
foreach ($env_var in $env_vars) {
Set-Item env:$env_var -Value $null
}
}
function PrepareAgent {
Write-Host "** Preparing Zabbix agent"
Prepare-Zbx-Agent-Config
ClearZbxEnv
}
$commandArgs=$args

View File

@ -1,19 +1,25 @@
# syntax=docker/dockerfile:1
# escape=`
ARG OS_BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}.8
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
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
ENV ZABBIX_USER_HOME_DIR="C:\zabbix" `
ZABBIX_CONF_DIR="C:\zabbix\conf"
ENV ZBX_PERSISTENTBUFFERFILE="$ZABBIX_USER_HOME_DIR\buffer\agent2.db" `
ZBX_USERPARAMETERDIR="${ZABBIX_USER_HOME_DIR}\user_scripts"
LABEL org.opencontainers.image.title="Zabbix agent 2" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
org.opencontainers.image.vendor="Zabbix SIA" `
@ -36,25 +42,27 @@ USER ContainerAdministrator
RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemDrive) + $env:PATH; `
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
`
$env:ZBX_HOME = [string]::Format('{0}\zabbix', $env:SystemDrive); `
[Environment]::SetEnvironmentVariable('ZBX_HOME', $env:ZBX_HOME, [EnvironmentVariableTarget]::Machine); `
[Environment]::SetEnvironmentVariable('ZABBIX_USER_HOME_DIR', $env:ZABBIX_USER_HOME_DIR, [EnvironmentVariableTarget]::Machine); `
`
Write-Host ('Verifying Zabbix agent 2 {0} ...' -f $env:ZBX_VERSION); `
zabbix_agent2.exe -V;
RUN Set-Location -Path $env:SystemDrive\.; `
`
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\conf\zabbix_agentd.d | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\conf\zabbix_agent2.d | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\enc | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\buffer | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_CONF_DIR | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_CONF_DIR\zabbix_agentd.d | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_CONF_DIR\zabbix_agent2.d | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\enc | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\enc_internal | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\buffer | Out-Null; `
New-Item -Force -ItemType directory -Path $env:ZBX_USERPARAMETERDIR | Out-Null; `
`
net accounts /MaxPWAge:unlimited; `
net user /add zabbix /expire:never /passwordreq:no; `
$acl = Get-Acl -Path $env:ZBX_HOME; `
$acl = Get-Acl -Path $env:ZABBIX_USER_HOME_DIR; `
$ace = New-Object Security.AccessControl.FileSystemAccessRule ('zabbix', 'Modify', 'ContainerInherit, ObjectInherit', 'InheritOnly', 'Allow'); `
$acl.AddAccessRule($ace); `
Set-Acl -AclObject $acl -Path $env:ZBX_HOME;
Set-Acl -AclObject $acl -Path $env:ZABBIX_USER_HOME_DIR;
USER zabbix

View File

@ -4,7 +4,6 @@ if ($env:DEBUG_MODE -eq "true") {
Set-PSDebug -trace 1
}
# Default Zabbix installation name
# Default Zabbix server host
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_HOST)) {
$env:ZBX_SERVER_HOST="zabbix-server"
@ -14,12 +13,9 @@ if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_PORT)) {
$env:ZBX_SERVER_PORT="10051"
}
# Default directories
# User 'zabbix' home directory
$ZabbixUserHomeDir="C:\zabbix"
# Configuration files directory
$ZabbixConfigDir="C:\zabbix\conf"
# Internal directory for TLS related files, used when TLS*File specified as plain text values
$ZabbixInternalEncDir="$env:ZABBIX_USER_HOME_DIR/enc_internal"
function Update-Config-Var {
Param (
@ -66,7 +62,7 @@ function Update-Config-Var {
}
if ($VarName -match '^TLS.*File$') {
$VarValue="$ZabbixUserHomeDir\enc\$VarValue"
$VarValue="$env:ZABBIX_USER_HOME_DIR\enc\$VarValue"
}
if ((Get-Content $ConfigPath | %{$_ -match "^$VarName="}) -contains $true -And $IsMultiple -ne $true) {
@ -97,7 +93,7 @@ function Update-Config-Var {
Write-Host "added"
}
else {
Add-Content -Path $ConfigPath -Value "$VarName=$VarValue"
Add-Content -Path $ConfigPath -Value "$VarName=$VarValue"
Write-Host "added at the end"
}
}
@ -119,34 +115,58 @@ function Update-Config-Multiple-Var {
}
}
function File-Process-From-Env {
Param (
[Parameter(Mandatory=$true, Position=0)]
[ValidateNotNullOrEmpty()]
[string] $ZbxAgentConfig,
[Parameter(Mandatory=$true, Position=1)]
[ValidateNotNullOrEmpty()]
[string] $VarName,
[Parameter(Mandatory=$false, Position=2)]
[string]$FileName = $null,
[Parameter(Mandatory=$false, Position=3)]
[string]$VarValue = $null
)
if (![string]::IsNullOrEmpty($VarValue)) {
$VarValue | Set-Content "$ZabbixInternalEncDir\$VarName"
$FileName="$ZabbixInternalEncDir\$VarName"
}
Update-Config-Var $ZbxAgentConfig "$VarName" "$FileName"
}
function Prepare-Zbx-Agent-Config {
Write-Host "** Preparing Zabbix agent 2 configuration file"
$ZbxAgentConfig="$ZabbixConfigDir\zabbix_agent2.conf"
$ZbxAgentConfig="$env:ZABBIX_CONF_DIR\zabbix_agent2.conf"
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVESERVERS)) {
if ($env:ZBX_PASSIVESERVERS -eq $null) {
$env:ZBX_PASSIVESERVERS=""
}
else {
$env:ZBX_PASSIVESERVERS=",$env:ZBX_PASSIVESERVERS"
}
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST + $env:ZBX_PASSIVESERVERS
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVESERVERS)) {
if ($env:ZBX_ACTIVESERVERS -eq $null) {
$env:ZBX_ACTIVESERVERS=""
}
else {
$env:ZBX_ACTIVESERVERS=",$env:ZBX_ACTIVESERVERS"
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST) -And ![string]::IsNullOrEmpty($env:ZBX_PASSIVESERVERS)) {
$env:ZBX_PASSIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_PASSIVESERVERS"
}
elseif (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST
}
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST + ":" + $env:ZBX_SERVER_PORT + $env:ZBX_ACTIVESERVERS
Update-Config-Var $ZbxAgentConfig "LogType" "console"
Update-Config-Var $ZbxAgentConfig "LogFile"
Update-Config-Var $ZbxAgentConfig "LogFileSize"
Update-Config-Var $ZbxAgentConfig "DebugLevel" "$env:ZBX_DEBUGLEVEL"
Update-Config-Var $ZbxAgentConfig "SourceIP"
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_PORT) -And $env:ZBX_SERVER_PORT -ne "10051") {
$env:ZBX_SERVER_HOST="$env:ZBX_SERVER_HOST:$env:ZBX_SERVER_PORT"
}
if (![string]::IsNullOrEmpty($env:ZBX_ACTIVESERVERS)) {
$env:ZBX_ACTIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_ACTIVESERVERS"
}
else {
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST
}
}
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVE_ALLOW)) {
$env:ZBX_PASSIVE_ALLOW="true"
@ -160,20 +180,27 @@ function Prepare-Zbx-Agent-Config {
Update-Config-Var $ZbxAgentConfig "Server"
}
Update-Config-Var $ZbxAgentConfig "ListenPort" "$env:ZBX_LISTENPORT"
Update-Config-Var $ZbxAgentConfig "ListenIP" "$env:ZBX_LISTENIP"
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVE_ALLOW)) {
$env:ZBX_ACTIVE_ALLOW="true"
}
if ($env:ZBX_PASSIVE_ALLOW -eq "true") {
if ($env:ZBX_ACTIVE_ALLOW -eq "true") {
Write-Host "** Using '$env:ZBX_ACTIVESERVERS' servers for active checks"
Update-Config-Var $ZbxAgentConfig "ServerActive" "$env:ZBX_ACTIVESERVERS"
}
else {
Update-Config-Var $ZbxAgentConfig "ServerActive"
}
Update-Config-Var $ZbxAgentConfig "LogType" "console"
Update-Config-Var $ZbxAgentConfig "LogFile"
Update-Config-Var $ZbxAgentConfig "LogFileSize"
Update-Config-Var $ZbxAgentConfig "DebugLevel" "$env:ZBX_DEBUGLEVEL"
Update-Config-Var $ZbxAgentConfig "SourceIP"
Update-Config-Var $ZbxAgentConfig "ListenPort" "$env:ZBX_LISTENPORT"
Update-Config-Var $ZbxAgentConfig "ListenIP" "$env:ZBX_LISTENIP"
Update-Config-Var $ZbxAgentConfig "HeartbeatFrequency" "$env:ZBX_HEARTBEAT_FREQUENCY"
Update-Config-Var $ZbxAgentConfig "ForceActiveChecksOnStart" "$env:ZBX_FORCEACTIVECHECKSONSTART"
@ -183,7 +210,7 @@ function Prepare-Zbx-Agent-Config {
if ($env:ZBX_ENABLEPERSISTENTBUFFER -eq "true") {
Update-Config-Var $ZbxAgentConfig "EnablePersistentBuffer" "1"
Update-Config-Var $ZbxAgentConfig "PersistentBufferFile" "$ZabbixUserHomeDir\buffer\agent2.db"
Update-Config-Var $ZbxAgentConfig "PersistentBufferFile" "$env:ZABBIX_USER_HOME_DIR\buffer\agent2.db"
Update-Config-Var $ZbxAgentConfig "PersistentBufferPeriod" "$env:ZBX_PERSISTENTBUFFERPERIOD"
}
else {
@ -215,23 +242,23 @@ function Prepare-Zbx-Agent-Config {
Update-Config-Var $ZbxAgentConfig "Include" ".\zabbix_agent2.d\plugins.d\*.conf"
Update-Config-Var $ZbxAgentConfig "Include" ".\zabbix_agentd.d\*.conf" $true
Update-Config-Var $ZbxAgentConfig "UnsafeUserParameters" "$env:ZBX_UNSAFEUSERPARAMETERS"
Update-Config-Var $ZbxAgentConfig "UserParameterDir" "$ZabbixUserHomeDir\user_scripts\"
Update-Config-Var $ZbxAgentConfig "UserParameterDir" "$env:ZBX_USERPARAMETERDIR"
Update-Config-Var $ZbxAgentConfig "TLSConnect" "$env:ZBX_TLSCONNECT"
Update-Config-Var $ZbxAgentConfig "TLSAccept" "$env:ZBX_TLSACCEPT"
Update-Config-Var $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE"
Update-Config-Var $ZbxAgentConfig "TLSCRLFile" "$env:ZBX_TLSCRLFILE"
File-Process-From-Env $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE" "$env:ZBX_TLSCA"
File-Process-From-Env $ZbxAgentConfig "TLSCRLFile" "$env:ZBX_TLSCRLFILE" "$env:ZBX_TLSCRL"
Update-Config-Var $ZbxAgentConfig "TLSServerCertIssuer" "$env:ZBX_TLSSERVERCERTISSUER"
Update-Config-Var $ZbxAgentConfig "TLSServerCertSubject" "$env:ZBX_TLSSERVERCERTSUBJECT"
Update-Config-Var $ZbxAgentConfig "TLSCertFile" "$env:ZBX_TLSCERTFILE"
File-Process-From-Env $ZbxAgentConfig "TLSCertFile" "$env:ZBX_TLSCERTFILE" "$env:ZBX_TLSCERT"
Update-Config-Var $ZbxAgentConfig "TLSCipherAll" "$env:ZBX_TLSCIPHERALL"
Update-Config-Var $ZbxAgentConfig "TLSCipherAll13" "$env:ZBX_TLSCIPHERALL13"
Update-Config-Var $ZbxAgentConfig "TLSCipherCert" "$env:ZBX_TLSCIPHERCERT"
Update-Config-Var $ZbxAgentConfig "TLSCipherCert13" "$env:ZBX_TLSCIPHERCERT13"
Update-Config-Var $ZbxAgentConfig "TLSCipherPSK" "$env:ZBX_TLSCIPHERPSK"
Update-Config-Var $ZbxAgentConfig "TLSCipherPSK13" "$env:ZBX_TLSCIPHERPSK13"
Update-Config-Var $ZbxAgentConfig "TLSKeyFile" "$env:ZBX_TLSKEYFILE"
File-Process-From-Env $ZbxAgentConfig "TLSKeyFile" "$env:ZBX_TLSKEYFILE" "$env:ZBX_TLSKEY"
Update-Config-Var $ZbxAgentConfig "TLSPSKIdentity" "$env:ZBX_TLSPSKIDENTITY"
Update-Config-Var $ZbxAgentConfig "TLSPSKFile" "$env:ZBX_TLSPSKFILE"
File-Process-From-Env $ZbxAgentConfig "TLSPSKFile" "$env:ZBX_TLSPSKFILE" "$env:ZBX_TLSPSK"
Update-Config-Multiple-Var $ZbxAgentConfig "DenyKey" "$env:ZBX_DENYKEY"
Update-Config-Multiple-Var $ZbxAgentConfig "AllowKey" "$env:ZBX_ALLOWKEY"
@ -241,16 +268,28 @@ function Prepare-Zbx-Agent-Config {
function Prepare-Zbx-Agent-Plugins-Config {
Write-Host "** Preparing Zabbix agent 2 (plugins) configuration files"
Update-Config-Var "$ZabbixConfigDir\zabbix_agent2.d\plugins.d\mongodb.conf" "Plugins.MongoDB.System.Path" "$ZabbixUserHomeDir\zabbix-agent2-plugin\mongodb.exe"
Update-Config-Var "$ZabbixConfigDir\zabbix_agent2.d\plugins.d\postgresql.conf" "Plugins.PostgreSQL.System.Path" "$ZabbixUserHomeDir\zabbix-agent2-plugin\postgresql.exe"
Update-Config-Var "$ZabbixConfigDir\zabbix_agent2.d\plugins.d\mssql.conf" "Plugins.MSSQL.System.Path" "$ZabbixUserHomeDir\zabbix-agent2-plugin\mssql.exe"
Update-Config-Var "$ZabbixConfigDir\zabbix_agent2.d\plugins.d\ember.conf" "Plugins.EmberPlus.System.Path" "$ZabbixUserHomeDir\zabbix-agent2-plugin\ember-plus.exe"
Update-Config-Var "$env:ZABBIX_CONF_DIR\zabbix_agent2.d\plugins.d\mongodb.conf" "Plugins.MongoDB.System.Path" "$env:ZABBIX_USER_HOME_DIR\zabbix-agent2-plugin\mongodb.exe"
Update-Config-Var "$env:ZABBIX_CONF_DIR\zabbix_agent2.d\plugins.d\postgresql.conf" "Plugins.PostgreSQL.System.Path" "$env:ZABBIX_USER_HOME_DIR\zabbix-agent2-plugin\postgresql.exe"
Update-Config-Var "$env:ZABBIX_CONF_DIR\zabbix_agent2.d\plugins.d\mssql.conf" "Plugins.MSSQL.System.Path" "$env:ZABBIX_USER_HOME_DIR\zabbix-agent2-plugin\mssql.exe"
Update-Config-Var "$env:ZABBIX_CONF_DIR\zabbix_agent2.d\plugins.d\ember.conf" "Plugins.EmberPlus.System.Path" "$env:ZABBIX_USER_HOME_DIR\zabbix-agent2-plugin\ember-plus.exe"
}
function ClearZbxEnv() {
if ([string]::IsNullOrWhitespace($env:ZBX_CLEAR_ENV)) {
return
}
$env_vars=Get-ChildItem env:* | Where-Object {$_.Name -match "^ZBX_.*" } | foreach { $_.Name }
foreach ($env_var in $env_vars) {
Set-Item env:$env_var -Value $null
}
}
function PrepareAgent {
Write-Host "** Preparing Zabbix agent 2"
Prepare-Zbx-Agent-Config
Prepare-Zbx-Agent-Plugins-Config
ClearZbxEnv
}
$commandArgs=$args

View File

@ -1,7 +1,11 @@
# 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 GIT_VERSION=2.47.1
ARG NASM_VERSION=2.16.03
ARG VS_BUILDTOOLS_VERSION=17
ARG PCRE2_VERSION=10.44
ARG OPENSSL_VERSION=3.3.2
@ -10,16 +14,15 @@ ARG ZLIB_VERSION=1.3.1
ARG CURL_VERSION=8.11.1
ARG BUILD_ARCH=x64
ARG CPU_MODEL=AMD64
ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}.8
ARG GIT_URL=https://github.com/git-for-windows/git/releases/download/v2.47.1.windows.1/MinGit-2.47.1-64-bit.zip
ARG GIT_URL=https://github.com/git-for-windows/git/releases/download/v$GIT_VERSION.windows.1/MinGit-$GIT_VERSION-64-bit.zip
ARG PERL_URL=https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_54001_64bit_UCRT/strawberry-perl-5.40.0.1-64bit-portable.zip
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/17/release/vs_buildtools.exe
ARG NASM_URL=https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-installer-x64.exe
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/$VS_BUILDTOOLS_VERSION/release/vs_buildtools.exe
ARG NASM_URL=https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/win64/nasm-$NASM_VERSION-installer-x64.exe
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
@ -28,9 +31,9 @@ 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 `
VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL VS_BUILDTOOLS_VERSION=$VS_BUILDTOOLS_VERSION `
PCRE2_VERSION=$PCRE2_VERSION OPENSSL_VERSION=$OPENSSL_VERSION LIBMODBUS_VERSION=$LIBMODBUS_VERSION `
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL LIBMODBUS_URL=$LIBMODBUS_URL `
ZLIB_URL=$ZLIB_URL CURL_URL=$CURL_URL
@ -44,8 +47,6 @@ LABEL org.opencontainers.image.title="Zabbix agent build base for Windows" `
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
ADD --checksum=sha256:15b4b2e0f68122c2da9b195de5c330489a9c97d40b4a95d2822378dc14d780e7 $LIBMODBUS_URL C:\libmodbus.tar.gz
@ -54,6 +55,8 @@ ADD --checksum=sha256:a889ac9dbba3644271bd9d1302b5c22a088893719b72be3487bc3d401e
COPY modbus.vs16.* C:\build_src\libmodbus_project\
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Set-Location -Path $env:SystemDrive\.; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
`
@ -65,6 +68,9 @@ RUN Set-Location -Path $env:SystemDrive\.; `
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
[Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); `
`
New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; `
New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; `
`
Write-Host ('Downloading {0} ...' -f $env:GIT_URL); `
Invoke-WebRequest -OutFile $env:TEMP\git.zip -Uri $env:GIT_URL; `
`
@ -130,9 +136,9 @@ RUN Set-Location -Path $env:SystemDrive\.; `
--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 `
--channelUri https://aka.ms/vs/$env:VS_BUILDTOOLS_VERSION/release/channel `
--installChannelUri https://aka.ms/vs/$env:VS_BUILDTOOLS_VERSION/release/channel `
--channelId VisualStudio.$env:VS_BUILDTOOLS_VERSION.Release `
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
--add Microsoft.VisualStudio.Component.Windows11SDK.22621 `
--add Microsoft.VisualStudio.Component.VC.CMake.Project; `
@ -148,15 +154,8 @@ RUN Set-Location -Path $env:SystemDrive\.; `
Write-Host 'Visual Studio components installation cleanup'; `
Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; `
`
Write-Host 'Removing downloaded...'; `
Remove-Item -Force -Recurse $env:TEMP\*; `
Write-Host 'Build environment is ready...'; `
`
Set-Location -Path $env:SystemDrive\.; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
`
New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; `
New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; `
Set-Location -Path $env:BUILD_SRC; `
`
Write-Host 'Extracting PCRE2 archive ...'; `
@ -266,7 +265,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
set CL=/MP; `
nmake /S -f Makefile.vc `
mode=static `
VC=17 `
VC=$env:VS_BUILDTOOLS_VERSION `
DEBUG=no `
CC="""cl.exe /DCURL_DISABLE_LDAP /DCURL_DISABLE_LDAPS""" `
MACHINE=$env:BUILD_ARCH `
@ -280,7 +279,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
ZLIB_PATH=$env:BUILD_OUTPUT\zlib `
RTLIBCFG=static; `
`
Move-Item -Path $env:BUILD_SRC\curl\builds\libcurl-vc17-$env:BUILD_ARCH-release-static-ssl-static-zlib-static-sspi\ -Destination $env:BUILD_OUTPUT\curl; `
Move-Item -Path $env:BUILD_SRC\curl\builds\libcurl-vc$env:VS_BUILDTOOLS_VERSION-$env:BUILD_ARCH-release-static-ssl-static-zlib-static-sspi\ -Destination $env:BUILD_OUTPUT\curl; `
Remove-Item -Path $env:BUILD_SRC\curl\builds\* -Force -Recurse; `
Write-Host 'Curl is ready...'; `
`

View File

@ -1,22 +1,22 @@
# 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
ARG GOLANG_VERSION=1.23.2
ARG VS_BUILDTOOLS_VERSION=17
ARG MSYSTEM=UCRT64
ARG BUILD_ARCH=x64
ARG CPU_MODEL=AMD64
ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}.8
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-ucrt-rt_v12-rev0.7z
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/17/release/vs_buildtools.exe
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/$VS_BUILDTOOLS_VERSION/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
@ -24,8 +24,8 @@ 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 `
MINGW_URL=$MINGW_URL VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL GOLANG_VERSION=$GOLANG_VERSION MSYS2_URL=$MSYS2_URL `
BUILD_ARCH=$BUILD_ARCH `
MINGW_URL=$MINGW_URL VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL VS_BUILDTOOLS_VERSION=$VS_BUILDTOOLS_VERSION 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
@ -39,11 +39,11 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
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
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Set-Location -Path $env:SystemDrive\.; `
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
`
@ -55,6 +55,9 @@ RUN Set-Location -Path $env:SystemDrive\.; `
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
[Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); `
`
New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; `
New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; `
`
Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); `
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
`
@ -130,9 +133,9 @@ RUN Set-Location -Path $env:SystemDrive\.; `
--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 `
--channelUri https://aka.ms/vs/$env:VS_BUILDTOOLS_VERSION/release/channel `
--installChannelUri https://aka.ms/vs/$env:VS_BUILDTOOLS_VERSION/release/channel `
--channelId VisualStudio.$env:VS_BUILDTOOLS_VERSION.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) { `
@ -147,14 +150,8 @@ RUN Set-Location -Path $env:SystemDrive\.; `
Write-Host 'Visual Studio components installation cleanup'; `
Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; `
`
Write-Host 'Removing downloaded...'; `
Remove-Item -Force -Recurse $env:TEMP\*; `
Write-Host 'Build environment is ready...'; `
`
[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 ...'; `

View File

@ -4,15 +4,14 @@ ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}.8
ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent-${ZBX_VERSION}
FROM ${BUILD_BASE_IMAGE} as builder
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
FROM ${BUILD_BASE_IMAGE} AS builder
ARG MAJOR_VERSION
ARG ZBX_VERSION
ARG ZABBIX_VERSION_RC_NUM=2400
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
ARG GIT_BRANCH
ARG ZABBIX_VERSION_RC_NUM=2400
ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION ZBX_VERSION=$ZBX_VERSION GIT_BRANCH=${GIT_BRANCH:-$ZBX_VERSION} `
ZABBIX_VERSION_RC_NUM=$ZABBIX_VERSION_RC_NUM `
@ -44,7 +43,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
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); `
Write-Host ('Building Zabbix agent {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; `
@ -71,4 +70,5 @@ RUN Set-Location -Path $env:SystemDrive\.; `
Copy-Item -Path $env:ZBX_SOURCES_DIR\bin\win64\zabbix_get.exe $env:ZBX_OUTPUT_DIR\bin; `
Copy-Item -Path $env:ZBX_SOURCES_DIR\bin\win64\zabbix_sender.exe $env:ZBX_OUTPUT_DIR\bin; `
Copy-Item -Path $env:ZBX_SOURCES_DIR\conf\zabbix_agentd.win.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agentd.conf; `
nmake /S -f Makefile clean; `
Write-Host 'Zabbix binaries are compiled...';

View File

@ -4,13 +4,12 @@ ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}.8
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';"]
ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}.8
ARG MAJOR_VERSION
ARG ZBX_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
@ -38,6 +37,8 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
org.opencontainers.image.version="${ZBX_VERSION}" `
org.opencontainers.image.source="${ZBX_SOURCES}"
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
RUN Set-Location -Path $env:SystemDrive\.; `
`
New-Item -ItemType directory -Path $env:ZBX_SOURCES_DIR | Out-Null; `
@ -53,7 +54,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
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); `
Write-Host ('Building Zabbix agent 2 {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; `