diff --git a/.github/workflows/images_build_windows.yml b/.github/workflows/images_build_windows.yml index 03507fdaae..66ead07196 100644 --- a/.github/workflows/images_build_windows.yml +++ b/.github/workflows/images_build_windows.yml @@ -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 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml deleted file mode 100644 index 781e310963..0000000000 --- a/.github/workflows/sonarcloud.yml +++ /dev/null @@ -1,79 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# This workflow helps you trigger a SonarCloud analysis of your code and populates -# GitHub Code Scanning alerts with the vulnerabilities found. -# Free for open source project. - -# 1. Login to SonarCloud.io using your GitHub account - -# 2. Import your project on SonarCloud -# * Add your GitHub organization first, then add your repository as a new project. -# * Please note that many languages are eligible for automatic analysis, -# which means that the analysis will start automatically without the need to set up GitHub Actions. -# * This behavior can be changed in Administration > Analysis Method. -# -# 3. Follow the SonarCloud in-product tutorial -# * a. Copy/paste the Project Key and the Organization Key into the args parameter below -# (You'll find this information in SonarCloud. Click on "Information" at the bottom left) -# -# * b. Generate a new token and add it to your Github repository's secrets using the name SONAR_TOKEN -# (On SonarCloud, click on your avatar on top-right > My account > Security -# or go directly to https://sonarcloud.io/account/security/) - -# Feel free to take a look at our documentation (https://docs.sonarcloud.io/getting-started/github/) -# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/help/sc/9) - -name: SonarCloud analysis - -on: - push: - branches: [ "7.0" ] - pull_request: - branches: [ "7.0" ] - workflow_dispatch: - -permissions: - pull-requests: read # allows SonarCloud to decorate PRs with analysis results - -jobs: - Analysis: - runs-on: ubuntu-latest - - steps: - - name: Block egress traffic - uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 - with: - egress-policy: audit - - - name: Checkout repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - # Disabling shallow clone is recommended for improving relevancy of reporting - fetch-depth: 0 - - - name: Analyze with SonarCloud - - # You can pin the exact commit or the version. - # uses: SonarSource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92 - uses: SonarSource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92 # v2.3.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) - with: - # Additional arguments for the sonarcloud scanner - args: - # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) - # mandatory - -Dsonar.projectKey=zabbix_zabbix-docker - -Dsonar.organization=zabbix - # Comma-separated paths to directories containing main source files. - #-Dsonar.sources= # optional, default is project base directory - # When you need the analysis to take place in a directory other than the one from which it was launched - #-Dsonar.projectBaseDir= # optional, default is . - # Comma-separated paths to directories containing test source files. - #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ - # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing. - #-Dsonar.verbose= # optional, default is false diff --git a/Dockerfiles/agent/windows/Dockerfile b/Dockerfiles/agent/windows/Dockerfile index 2e4638e700..02bb23d09e 100644 --- a/Dockerfiles/agent/windows/Dockerfile +++ b/Dockerfiles/agent/windows/Dockerfile @@ -1,19 +1,24 @@ # syntax=docker/dockerfile:1 # escape=` +ARG OS_BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022 + ARG MAJOR_VERSION=6.0 ARG ZBX_VERSION=${MAJOR_VERSION}.37 -ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent-${ZBX_VERSION} -ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022 +ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent-${ZBX_VERSION} 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 " ` 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 diff --git a/Dockerfiles/agent/windows/docker-entrypoint.ps1 b/Dockerfiles/agent/windows/docker-entrypoint.ps1 index 67d7196060..cb0363d860 100644 --- a/Dockerfiles/agent/windows/docker-entrypoint.ps1 +++ b/Dockerfiles/agent/windows/docker-entrypoint.ps1 @@ -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" + if ($env:ZBX_ACTIVESERVERS -eq $null) { + $env:ZBX_ACTIVESERVERS="" } - $env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST + $env:ZBX_PASSIVESERVERS - - if ([string]::IsNullOrWhitespace($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" } - else { - $env:ZBX_ACTIVESERVERS=",$env:ZBX_ACTIVESERVERS" + 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" } @@ -177,6 +193,19 @@ function Prepare-Zbx-Agent-Config { 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" Update-Config-Var $ZbxAgentConfig "HostInterfaceItem" "$env:ZBX_HOSTINTERFACEITEM" @@ -193,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 diff --git a/Dockerfiles/agent2/windows/Dockerfile b/Dockerfiles/agent2/windows/Dockerfile index d08fc10bf4..5e053ea899 100644 --- a/Dockerfiles/agent2/windows/Dockerfile +++ b/Dockerfiles/agent2/windows/Dockerfile @@ -1,19 +1,25 @@ # syntax=docker/dockerfile:1 # escape=` +ARG OS_BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022 + ARG MAJOR_VERSION=6.0 ARG ZBX_VERSION=${MAJOR_VERSION}.37 -ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent2-${ZBX_VERSION} -ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022 +ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent2-${ZBX_VERSION} 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 " ` 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 diff --git a/Dockerfiles/agent2/windows/docker-entrypoint.ps1 b/Dockerfiles/agent2/windows/docker-entrypoint.ps1 index c23534c769..55a0917a23 100644 --- a/Dockerfiles/agent2/windows/docker-entrypoint.ps1 +++ b/Dockerfiles/agent2/windows/docker-entrypoint.ps1 @@ -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" + if ($env:ZBX_ACTIVESERVERS -eq $null) { + $env:ZBX_ACTIVESERVERS="" } - $env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST + $env:ZBX_PASSIVESERVERS - - if ([string]::IsNullOrWhitespace($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" } - else { - $env:ZBX_ACTIVESERVERS=",$env:ZBX_ACTIVESERVERS" + 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,28 @@ 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" if ([string]::IsNullOrWhitespace($env:ZBX_ENABLEPERSISTENTBUFFER)) { @@ -182,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 { @@ -214,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" @@ -240,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 diff --git a/Dockerfiles/build-base/windows/Dockerfile.agent b/Dockerfiles/build-base/windows/Dockerfile.agent index 5ca1b04300..ee48d2aac0 100644 --- a/Dockerfiles/build-base/windows/Dockerfile.agent +++ b/Dockerfiles/build-base/windows/Dockerfile.agent @@ -1,36 +1,39 @@ # 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.43 +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.1.5 -ARG LIBMODBUS_VERSION=3.1.10 +ARG LIBMODBUS_VERSION=3.1.11 ARG ZLIB_VERSION=1.3.1 -ARG CURL_VERSION=8.10.1 +ARG CURL_VERSION=8.11.1 ARG BUILD_ARCH=x64 -ARG CPU_MODEL=AMD64 ARG MAJOR_VERSION=6.0 ARG ZBX_VERSION=${MAJOR_VERSION}.37 -ARG GIT_URL=https://github.com/git-for-windows/git/releases/download/v2.33.0.windows.2/MinGit-2.33.0.2-busybox-64-bit.zip -ARG PERL_URL=https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_53822_64bit/strawberry-perl-5.38.2.2-64bit-portable.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://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz +ARG OPENSSL_URL=https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz ARG LIBMODBUS_URL=https://github.com/stephane/libmodbus/archive/refs/tags/v$LIBMODBUS_VERSION.tar.gz 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,10 +47,16 @@ 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:6ae015467dabf0469b139ada93319327be24b98251ffaeceda0221848dc09262 $OPENSSL_URL C:\openssl.tar.gz +ADD --checksum=sha256:15b4b2e0f68122c2da9b195de5c330489a9c97d40b4a95d2822378dc14d780e7 $LIBMODBUS_URL C:\libmodbus.tar.gz +ADD --checksum=sha256:9A93B2B7DFDAC77CEBA5A558A580E74667DD6FEDE4585B91EEFB60F03B72DF23 $ZLIB_URL C:\zlib.tar.gz +ADD --checksum=sha256:a889ac9dbba3644271bd9d1302b5c22a088893719b72be3487bc3d401e5c4e80 $CURL_URL C:\curl.tar.gz 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; ` ` @@ -59,10 +68,13 @@ 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; ` ` - $sha256 = '273f55e881094d00877d64f56570b0c997c4da5dedcb26738d56481033c1eba1'; ` + $sha256 = '50b04b55425b5c465d076cdb184f63a0cd0f86f6ec8bb4d5860114a713d2c29a'; ` $d_sha256 = (Get-FileHash $env:TEMP\git.zip -Algorithm sha256).Hash; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` if ($d_sha256 -ne $sha256) { ` @@ -84,7 +96,7 @@ RUN Set-Location -Path $env:SystemDrive\.; ` Write-Host ('Downloading {0} ...' -f $env:PERL_URL); ` Invoke-WebRequest -OutFile $env:TEMP\perl.zip -Uri $env:PERL_URL; ` ` - $sha256 = 'EA451686065D6338D7E4D4A04C9AF49F17951D15AA4C2E19AB8CB56FA2373440'; ` + $sha256 = '754f3e2a8e473dc68d1540c7802fb166a025f35ef18960c4564a31f8b5933907'; ` $d_sha256 = (Get-FileHash $env:TEMP\perl.zip -Algorithm sha256).Hash; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` if ($d_sha256 -ne $sha256) { ` @@ -124,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; ` @@ -142,92 +154,30 @@ 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 ('Downloading {0} ...' -f $env:PCRE2_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\pcre2.zip -Uri $env:PCRE2_URL; ` - ` - $sha256 = 'F2816E84DD7A402068797501BF69E24ECA18D882ADB2143DE9F831F39B850257'; ` - $d_sha256 = (Get-FileHash $env:TEMP\pcre2.zip -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum PCRE2 library ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\openssl.tar.gz -Uri $env:OPENSSL_URL; ` - ` - $sha256 = '6ae015467dabf0469b139ada93319327be24b98251ffaeceda0221848dc09262'; ` - $d_sha256 = (Get-FileHash $env:TEMP\openssl.tar.gz -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum OpenSSL library ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:LIBMODBUS_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\libmodbus.tar.gz -Uri $env:LIBMODBUS_URL; ` - ` - $sha256 = 'E93503749CD89FDA4C8CF1EE6371A3A9CC1F0A921C165AFBBC4FD96D4813FA1A'; ` - $d_sha256 = (Get-FileHash $env:TEMP\libmodbus.tar.gz -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum Libmodbus library ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:ZLIB_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\zlib.tar.gz -Uri $env:ZLIB_URL; ` - ` - $sha256 = '9A93B2B7DFDAC77CEBA5A558A580E74667DD6FEDE4585B91EEFB60F03B72DF23'; ` - $d_sha256 = (Get-FileHash $env:TEMP\zlib.tar.gz -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum Zlib library ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:CURL_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\curl.tar.gz -Uri $env:CURL_URL; ` - ` - $sha256 = 'd15ebab765d793e2e96db090f0e172d127859d78ca6f6391d7eafecfd894bbc0'; ` - $d_sha256 = (Get-FileHash $env:TEMP\curl.tar.gz -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum Curl library ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` Write-Host 'Extracting PCRE2 archive ...'; ` - Expand-Archive -Path $env:TEMP\pcre2.zip -DestinationPath $env:BUILD_SRC; ` + 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; ` New-Item -ItemType directory -Path "$env:BUILD_SRC\pcre2\build" | Out-Null; ` ` Write-Host 'Extracting OpenSSL archive ...'; ` - tar -zxf $env:TEMP\openssl.tar.gz; ` + tar -zxf $env:SystemDrive\openssl.tar.gz; ` Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; ` ` Write-Host 'Extracting Libmodbus archive ...'; ` - tar -zxf $env:TEMP\libmodbus.tar.gz; ` + tar -zxf $env:SystemDrive\libmodbus.tar.gz; ` Move-Item -Path $env:BUILD_SRC\libmodbus-$env:LIBMODBUS_VERSION\ -Destination $env:BUILD_SRC\libmodbus; ` Move-Item -Path $env:BUILD_SRC\libmodbus_project\* -Destination $env:BUILD_SRC\libmodbus\src\win32; ` ` Write-Host 'Extracting Zlib archive ...'; ` - tar -zxf $env:TEMP\zlib.tar.gz; ` + tar -zxf $env:SystemDrive\zlib.tar.gz; ` Move-Item -Path $env:BUILD_SRC\zlib-$env:ZLIB_VERSION\ -Destination $env:BUILD_SRC\zlib; ` ` Write-Host 'Extracting CURL archive ...'; ` - tar -zxf $env:TEMP\curl.tar.gz; ` + tar -zxf $env:SystemDrive\curl.tar.gz; ` Move-Item -Path $env:BUILD_SRC\curl-$env:CURL_VERSION\ -Destination $env:BUILD_SRC\curl; ` ` Set-Location -Path $env:SystemDrive\.; ` @@ -315,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 ` @@ -329,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...'; ` ` diff --git a/Dockerfiles/build-base/windows/Dockerfile.agent2 b/Dockerfiles/build-base/windows/Dockerfile.agent2 index 89ee3770b4..2887f25fe6 100644 --- a/Dockerfiles/build-base/windows/Dockerfile.agent2 +++ b/Dockerfiles/build-base/windows/Dockerfile.agent2 @@ -1,31 +1,31 @@ # 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.43 +ARG PCRE2_VERSION=10.44 ARG OPENSSL_VERSION=3.1.5 ARG GOLANG_VERSION=1.23.2 +ARG VS_BUILDTOOLS_VERSION=17 ARG MSYSTEM=MINGW64 ARG BUILD_ARCH=x64 -ARG CPU_MODEL=AMD64 ARG MAJOR_VERSION=6.0 ARG ZBX_VERSION=${MAJOR_VERSION}.37 ARG MINGW_URL=https://github.com/niXman/mingw-builds-binaries/releases/download/8.5.0-rt_v10-rev0/x86_64-8.5.0-release-win32-sjlj-rt_v10-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 ARG PCRE2_URL=https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.zip -ARG OPENSSL_URL=https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz +ARG 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 @@ -35,10 +35,13 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" ` 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.licenses="GPL v2.0" ` org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" ` org.opencontainers.image.version="${ZBX_VERSION}" +ADD --checksum=sha256:21c6f0523abfd37a2f5cc85879d0ff32723ab496347f0d20793df888ecec3957 $PCRE2_URL C:\pcre2.zip +ADD --checksum=sha256:6ae015467dabf0469b139ada93319327be24b98251ffaeceda0221848dc09262 $OPENSSL_URL C:\openssl.tar.gz + SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] RUN Set-Location -Path $env:SystemDrive\.; ` @@ -52,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; ` ` @@ -80,7 +86,7 @@ RUN Set-Location -Path $env:SystemDrive\.; ` Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); ` Invoke-WebRequest -OutFile $env:TEMP\mingw.7z -Uri $env:MINGW_URL; ` ` - $sha256 = '55ED84E72DFF790D424254C9F4B900DD7D0605FF200564258E3B88654214E440'; ` + $sha256 = '55ed84e72dff790d424254c9f4b900dd7d0605ff200564258e3b88654214e440'; ` $d_sha256 = (Get-FileHash $env:TEMP\mingw.7z -Algorithm sha256).Hash; ` Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` if ($d_sha256 -ne $sha256) { ` @@ -127,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) { ` @@ -144,51 +150,17 @@ 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 ('Downloading {0} ...' -f $env:PCRE2_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\pcre2.zip -Uri $env:PCRE2_URL; ` - ` - $sha256 = 'F2816E84DD7A402068797501BF69E24ECA18D882ADB2143DE9F831F39B850257'; ` - $d_sha256 = (Get-FileHash $env:TEMP\pcre2.zip -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum PCRE2 library ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` - Write-Host ('Downloading {0} ...' -f $env:OPENSSL_URL); ` - Invoke-WebRequest -OutFile $env:TEMP\openssl.tar.gz -Uri $env:OPENSSL_URL; ` - ` - $sha256 = '6ae015467dabf0469b139ada93319327be24b98251ffaeceda0221848dc09262'; ` - $d_sha256 = (Get-FileHash $env:TEMP\openssl.tar.gz -Algorithm sha256).Hash; ` - Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); ` - if ($d_sha256 -ne $sha256) { ` - Write-Host ('Checksum OpenSSL library ({0}) failed!' -f $d_sha256); ` - exit 1; ` - }; ` - ` Write-Host 'Extracting PCRE2 archive ...'; ` - Expand-Archive -Path $env:TEMP\pcre2.zip -DestinationPath $env:BUILD_SRC; ` - ` - Write-Host 'Removing downloaded ...'; ` - Remove-Item -Force -Path $env:TEMP\pcre2.zip; ` + 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:TEMP\openssl.tar.gz"; ` - ` - Write-Host 'Removing downloaded...'; ` - Remove-Item -Force -Path $env:TEMP\openssl.tar.gz; ` + 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 ...'; ` @@ -206,7 +178,6 @@ RUN Set-Location -Path $env:SystemDrive\.; ` 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\man -Force -Recurse; ` Remove-Item -Path $env:BUILD_OUTPUT\pcre2\share -Force -Recurse; ` Write-Host 'PCRE2 is ready...'; ` ` diff --git a/Dockerfiles/build-mysql/windows/Dockerfile.agent b/Dockerfiles/build-mysql/windows/Dockerfile.agent index 3b8460514d..453a4eaef7 100644 --- a/Dockerfiles/build-mysql/windows/Dockerfile.agent +++ b/Dockerfiles/build-mysql/windows/Dockerfile.agent @@ -6,13 +6,12 @@ ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent-${ZBX_VERSION} FROM ${BUILD_BASE_IMAGE} AS builder -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] - 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...'; diff --git a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 index 75867dcfc1..7391e802da 100644 --- a/Dockerfiles/build-mysql/windows/Dockerfile.agent2 +++ b/Dockerfiles/build-mysql/windows/Dockerfile.agent2 @@ -6,11 +6,10 @@ 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=6.0 -ARG ZBX_VERSION=${MAJOR_VERSION}.37 +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; ` @@ -109,7 +110,6 @@ RUN Set-Location -Path $env:SystemDrive\.; ` 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; `