mirror of
https://github.com/zabbix/zabbix-docker.git
synced 2025-02-12 15:59:25 +01:00
Fixed minor issues with Windows containers
This commit is contained in:
parent
e6da65896d
commit
fa2eaced48
8
.github/workflows/images_build_windows.yml
vendored
8
.github/workflows/images_build_windows.yml
vendored
@ -249,7 +249,7 @@ jobs:
|
|||||||
Write-Host @"
|
Write-Host @"
|
||||||
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION
|
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION
|
||||||
--label org.opencontainers.image.created=$Env:LABEL_CREATED
|
--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
|
--file=$dockerfile
|
||||||
$tags
|
$tags
|
||||||
$context
|
$context
|
||||||
@ -257,7 +257,7 @@ jobs:
|
|||||||
|
|
||||||
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION `
|
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION `
|
||||||
--label org.opencontainers.image.created=$Env:LABEL_CREATED `
|
--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 `
|
--file=$dockerfile `
|
||||||
$tags `
|
$tags `
|
||||||
$context
|
$context
|
||||||
@ -717,7 +717,7 @@ jobs:
|
|||||||
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION
|
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION
|
||||||
--label org.opencontainers.image.created=$Env:LABEL_CREATED
|
--label org.opencontainers.image.created=$Env:LABEL_CREATED
|
||||||
--build-arg=BUILD_BASE_IMAGE=$base_build_image
|
--build-arg=BUILD_BASE_IMAGE=$base_build_image
|
||||||
--build-arg=BASE_IMAGE=$base_image
|
--build-arg=OS_BASE_IMAGE=$base_image
|
||||||
--file=$dockerfile
|
--file=$dockerfile
|
||||||
$tags
|
$tags
|
||||||
$context
|
$context
|
||||||
@ -726,7 +726,7 @@ jobs:
|
|||||||
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION `
|
docker build --label org.opencontainers.image.revision=$Env:LABEL_REVISION `
|
||||||
--label org.opencontainers.image.created=$Env:LABEL_CREATED `
|
--label org.opencontainers.image.created=$Env:LABEL_CREATED `
|
||||||
--build-arg=BUILD_BASE_IMAGE=$base_build_image `
|
--build-arg=BUILD_BASE_IMAGE=$base_build_image `
|
||||||
--build-arg=BASE_IMAGE=$base_image `
|
--build-arg=OS_BASE_IMAGE=$base_image `
|
||||||
--file=$dockerfile `
|
--file=$dockerfile `
|
||||||
$tags `
|
$tags `
|
||||||
$context
|
$context
|
||||||
|
79
.github/workflows/sonarcloud.yml
vendored
79
.github/workflows/sonarcloud.yml
vendored
@ -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
|
|
@ -1,19 +1,22 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
# escape=`
|
# escape=`
|
||||||
|
ARG OS_BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
|
||||||
|
|
||||||
ARG MAJOR_VERSION=5.0
|
ARG MAJOR_VERSION=5.0
|
||||||
ARG ZBX_VERSION=${MAJOR_VERSION}.45
|
ARG ZBX_VERSION=${MAJOR_VERSION}.45
|
||||||
|
|
||||||
ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent-${ZBX_VERSION}
|
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 ${BUILD_BASE_IMAGE} AS builder
|
||||||
|
FROM ${OS_BASE_IMAGE}
|
||||||
FROM $BASE_IMAGE
|
|
||||||
|
|
||||||
ARG MAJOR_VERSION
|
ARG MAJOR_VERSION
|
||||||
ARG ZBX_VERSION
|
ARG ZBX_VERSION
|
||||||
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
||||||
|
|
||||||
|
ENV ZABBIX_USER_HOME_DIR="C:\zabbix" `
|
||||||
|
ZABBIX_CONF_DIR="C:\zabbix\conf"
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="Zabbix agent" `
|
LABEL org.opencontainers.image.title="Zabbix agent" `
|
||||||
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
||||||
org.opencontainers.image.vendor="Zabbix SIA" `
|
org.opencontainers.image.vendor="Zabbix SIA" `
|
||||||
@ -36,25 +39,24 @@ USER ContainerAdministrator
|
|||||||
RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemDrive) + $env:PATH; `
|
RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemDrive) + $env:PATH; `
|
||||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||||
`
|
`
|
||||||
$env:ZBX_HOME = [string]::Format('{0}\zabbix', $env:SystemDrive); `
|
[Environment]::SetEnvironmentVariable('ZABBIX_USER_HOME_DIR', $env:ZABBIX_USER_HOME_DIR, [EnvironmentVariableTarget]::Machine); `
|
||||||
[Environment]::SetEnvironmentVariable('ZBX_HOME', $env:ZBX_HOME, [EnvironmentVariableTarget]::Machine); `
|
|
||||||
`
|
`
|
||||||
Write-Host ('Verifying Zabbix agent {0} ...' -f $env:ZBX_VERSION); `
|
Write-Host ('Verifying Zabbix agent {0} ...' -f $env:ZBX_VERSION); `
|
||||||
zabbix_agentd.exe -V;
|
zabbix_agentd.exe -V;
|
||||||
|
|
||||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
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:ZABBIX_CONF_DIR | Out-Null; `
|
||||||
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\enc | Out-Null; `
|
New-Item -Force -ItemType directory -Path $env:ZABBIX_CONF_DIR\zabbix_agentd.d | Out-Null; `
|
||||||
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\modules | Out-Null; `
|
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\enc | Out-Null; `
|
||||||
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\buffer | Out-Null; `
|
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\enc_internal | Out-Null; `
|
||||||
`
|
`
|
||||||
net accounts /MaxPWAge:unlimited; `
|
net accounts /MaxPWAge:unlimited; `
|
||||||
net user /add zabbix /expire:never /passwordreq:no; `
|
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'); `
|
$ace = New-Object Security.AccessControl.FileSystemAccessRule ('zabbix', 'Modify', 'ContainerInherit, ObjectInherit', 'InheritOnly', 'Allow'); `
|
||||||
$acl.AddAccessRule($ace); `
|
$acl.AddAccessRule($ace); `
|
||||||
Set-Acl -AclObject $acl -Path $env:ZBX_HOME;
|
Set-Acl -AclObject $acl -Path $env:ZABBIX_USER_HOME_DIR;
|
||||||
|
|
||||||
USER zabbix
|
USER zabbix
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ if ($env:DEBUG_MODE -eq "true") {
|
|||||||
Set-PSDebug -trace 1
|
Set-PSDebug -trace 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Default Zabbix installation name
|
|
||||||
# Default Zabbix server host
|
# Default Zabbix server host
|
||||||
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_HOST)) {
|
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_HOST)) {
|
||||||
$env:ZBX_SERVER_HOST="zabbix-server"
|
$env:ZBX_SERVER_HOST="zabbix-server"
|
||||||
@ -14,12 +13,9 @@ if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_PORT)) {
|
|||||||
$env:ZBX_SERVER_PORT="10051"
|
$env:ZBX_SERVER_PORT="10051"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Default directories
|
# Default directories
|
||||||
# User 'zabbix' home directory
|
# Internal directory for TLS related files, used when TLS*File specified as plain text values
|
||||||
$ZabbixUserHomeDir="C:\zabbix"
|
$ZabbixInternalEncDir="$env:ZABBIX_USER_HOME_DIR/enc_internal"
|
||||||
# Configuration files directory
|
|
||||||
$ZabbixConfigDir="C:\zabbix\conf"
|
|
||||||
|
|
||||||
function Update-Config-Var {
|
function Update-Config-Var {
|
||||||
Param (
|
Param (
|
||||||
@ -66,7 +62,7 @@ function Update-Config-Var {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($VarName -match '^TLS.*File$') {
|
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) {
|
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 {
|
function Prepare-Zbx-Agent-Config {
|
||||||
Write-Host "** Preparing Zabbix agent configuration file"
|
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=""
|
$env:ZBX_PASSIVESERVERS=""
|
||||||
}
|
}
|
||||||
else {
|
if ($env:ZBX_ACTIVESERVERS -eq $null) {
|
||||||
$env:ZBX_PASSIVESERVERS=",$env:ZBX_PASSIVESERVERS"
|
|
||||||
}
|
|
||||||
|
|
||||||
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST + $env:ZBX_PASSIVESERVERS
|
|
||||||
|
|
||||||
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVESERVERS)) {
|
|
||||||
$env:ZBX_ACTIVESERVERS=""
|
$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
|
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
|
||||||
|
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_PORT) -And $env:ZBX_SERVER_PORT -ne "10051") {
|
||||||
Update-Config-Var $ZbxAgentConfig "LogType" "console"
|
$env:ZBX_SERVER_HOST="$env:ZBX_SERVER_HOST:$env:ZBX_SERVER_PORT"
|
||||||
Update-Config-Var $ZbxAgentConfig "LogFile"
|
}
|
||||||
Update-Config-Var $ZbxAgentConfig "LogFileSize"
|
if (![string]::IsNullOrEmpty($env:ZBX_ACTIVESERVERS)) {
|
||||||
Update-Config-Var $ZbxAgentConfig "DebugLevel" "$env:ZBX_DEBUGLEVEL"
|
$env:ZBX_ACTIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_ACTIVESERVERS"
|
||||||
Update-Config-Var $ZbxAgentConfig "SourceIP"
|
}
|
||||||
Update-Config-Var $ZbxAgentConfig "LogRemoteCommands" "$env:ZBX_LOGREMOTECOMMANDS"
|
else {
|
||||||
|
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVE_ALLOW)) {
|
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVE_ALLOW)) {
|
||||||
$env:ZBX_PASSIVE_ALLOW="true"
|
$env:ZBX_PASSIVE_ALLOW="true"
|
||||||
@ -161,10 +181,6 @@ function Prepare-Zbx-Agent-Config {
|
|||||||
Update-Config-Var $ZbxAgentConfig "Server"
|
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)) {
|
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVE_ALLOW)) {
|
||||||
$env:ZBX_ACTIVE_ALLOW="true"
|
$env:ZBX_ACTIVE_ALLOW="true"
|
||||||
}
|
}
|
||||||
@ -177,6 +193,17 @@ function Prepare-Zbx-Agent-Config {
|
|||||||
Update-Config-Var $ZbxAgentConfig "ServerActive"
|
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 "HostInterface" "$env:ZBX_HOSTINTERFACE"
|
Update-Config-Var $ZbxAgentConfig "HostInterface" "$env:ZBX_HOSTINTERFACE"
|
||||||
Update-Config-Var $ZbxAgentConfig "HostInterfaceItem" "$env:ZBX_HOSTINTERFACEITEM"
|
Update-Config-Var $ZbxAgentConfig "HostInterfaceItem" "$env:ZBX_HOSTINTERFACEITEM"
|
||||||
|
|
||||||
@ -193,27 +220,38 @@ function Prepare-Zbx-Agent-Config {
|
|||||||
# Please use include to enable Perfcounter feature
|
# Please use include to enable Perfcounter feature
|
||||||
# update_config_multiple_var $ZBX_AGENT_CONFIG "PerfCounter" $env:ZBX_PERFCOUNTER
|
# update_config_multiple_var $ZBX_AGENT_CONFIG "PerfCounter" $env:ZBX_PERFCOUNTER
|
||||||
Update-Config-Var $ZbxAgentConfig "Timeout" "$env:ZBX_TIMEOUT"
|
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 "UnsafeUserParameters" "$env:ZBX_UNSAFEUSERPARAMETERS"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSConnect" "$env:ZBX_TLSCONNECT"
|
Update-Config-Var $ZbxAgentConfig "TLSConnect" "$env:ZBX_TLSCONNECT"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSAccept" "$env:ZBX_TLSACCEPT"
|
Update-Config-Var $ZbxAgentConfig "TLSAccept" "$env:ZBX_TLSACCEPT"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE"
|
File-Process-From-Env $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE" "$env:ZBX_TLSCA"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSCRLFile" "$env:ZBX_TLSCRLFILE"
|
File-Process-From-Env $ZbxAgentConfig "TLSCRLFile" "$env:ZBX_TLSCRLFILE" "$env:ZBX_TLSCRL"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSServerCertIssuer" "$env:ZBX_TLSSERVERCERTISSUER"
|
Update-Config-Var $ZbxAgentConfig "TLSServerCertIssuer" "$env:ZBX_TLSSERVERCERTISSUER"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSServerCertSubject" "$env:ZBX_TLSSERVERCERTSUBJECT"
|
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 "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 "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 "DenyKey" "$env:ZBX_DENYKEY"
|
||||||
Update-Config-Multiple-Var $ZbxAgentConfig "AllowKey" "$env:ZBX_ALLOWKEY"
|
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 {
|
function PrepareAgent {
|
||||||
Write-Host "** Preparing Zabbix agent"
|
Write-Host "** Preparing Zabbix agent"
|
||||||
Prepare-Zbx-Agent-Config
|
Prepare-Zbx-Agent-Config
|
||||||
|
ClearZbxEnv
|
||||||
}
|
}
|
||||||
|
|
||||||
$commandArgs=$args
|
$commandArgs=$args
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
# escape=`
|
# escape=`
|
||||||
|
ARG OS_BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
|
||||||
|
|
||||||
ARG MAJOR_VERSION=5.0
|
ARG MAJOR_VERSION=5.0
|
||||||
ARG ZBX_VERSION=${MAJOR_VERSION}.45
|
ARG ZBX_VERSION=${MAJOR_VERSION}.45
|
||||||
|
|
||||||
ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent2-${ZBX_VERSION}
|
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 ${BUILD_BASE_IMAGE} AS builder
|
||||||
|
FROM ${OS_BASE_IMAGE}
|
||||||
FROM $BASE_IMAGE
|
|
||||||
|
|
||||||
ARG MAJOR_VERSION
|
ARG MAJOR_VERSION
|
||||||
ARG ZBX_VERSION
|
ARG ZBX_VERSION
|
||||||
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
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"
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="Zabbix agent 2" `
|
LABEL org.opencontainers.image.title="Zabbix agent 2" `
|
||||||
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
||||||
org.opencontainers.image.vendor="Zabbix SIA" `
|
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; `
|
RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemDrive) + $env:PATH; `
|
||||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||||
`
|
`
|
||||||
$env:ZBX_HOME = [string]::Format('{0}\zabbix', $env:SystemDrive); `
|
[Environment]::SetEnvironmentVariable('ZABBIX_USER_HOME_DIR', $env:ZABBIX_USER_HOME_DIR, [EnvironmentVariableTarget]::Machine); `
|
||||||
[Environment]::SetEnvironmentVariable('ZBX_HOME', $env:ZBX_HOME, [EnvironmentVariableTarget]::Machine); `
|
|
||||||
`
|
`
|
||||||
Write-Host ('Verifying Zabbix agent 2 {0} ...' -f $env:ZBX_VERSION); `
|
Write-Host ('Verifying Zabbix agent 2 {0} ...' -f $env:ZBX_VERSION); `
|
||||||
zabbix_agent2.exe -V;
|
zabbix_agent2.exe -V;
|
||||||
|
|
||||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
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:ZABBIX_CONF_DIR | Out-Null; `
|
||||||
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\conf\zabbix_agent2.d | Out-Null; `
|
New-Item -Force -ItemType directory -Path $env:ZABBIX_CONF_DIR\zabbix_agentd.d | Out-Null; `
|
||||||
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\enc | Out-Null; `
|
New-Item -Force -ItemType directory -Path $env:ZABBIX_USER_HOME_DIR\enc | Out-Null; `
|
||||||
New-Item -Force -ItemType directory -Path $env:ZBX_HOME\buffer | 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; `
|
||||||
`
|
`
|
||||||
net accounts /MaxPWAge:unlimited; `
|
net accounts /MaxPWAge:unlimited; `
|
||||||
net user /add zabbix /expire:never /passwordreq:no; `
|
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'); `
|
$ace = New-Object Security.AccessControl.FileSystemAccessRule ('zabbix', 'Modify', 'ContainerInherit, ObjectInherit', 'InheritOnly', 'Allow'); `
|
||||||
$acl.AddAccessRule($ace); `
|
$acl.AddAccessRule($ace); `
|
||||||
Set-Acl -AclObject $acl -Path $env:ZBX_HOME;
|
Set-Acl -AclObject $acl -Path $env:ZABBIX_USER_HOME_DIR;
|
||||||
|
|
||||||
USER zabbix
|
USER zabbix
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ if ($env:DEBUG_MODE -eq "true") {
|
|||||||
Set-PSDebug -trace 1
|
Set-PSDebug -trace 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Default Zabbix installation name
|
|
||||||
# Default Zabbix server host
|
# Default Zabbix server host
|
||||||
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_HOST)) {
|
if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_HOST)) {
|
||||||
$env:ZBX_SERVER_HOST="zabbix-server"
|
$env:ZBX_SERVER_HOST="zabbix-server"
|
||||||
@ -14,12 +13,9 @@ if ([string]::IsNullOrWhitespace($env:ZBX_SERVER_PORT)) {
|
|||||||
$env:ZBX_SERVER_PORT="10051"
|
$env:ZBX_SERVER_PORT="10051"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Default directories
|
# Default directories
|
||||||
# User 'zabbix' home directory
|
# Internal directory for TLS related files, used when TLS*File specified as plain text values
|
||||||
$ZabbixUserHomeDir="C:\zabbix"
|
$ZabbixInternalEncDir="$env:ZABBIX_USER_HOME_DIR/enc_internal"
|
||||||
# Configuration files directory
|
|
||||||
$ZabbixConfigDir="C:\zabbix\conf"
|
|
||||||
|
|
||||||
function Update-Config-Var {
|
function Update-Config-Var {
|
||||||
Param (
|
Param (
|
||||||
@ -66,7 +62,7 @@ function Update-Config-Var {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($VarName -match '^TLS.*File$') {
|
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) {
|
if ((Get-Content $ConfigPath | %{$_ -match "^$VarName="}) -contains $true -And $IsMultiple -ne $true) {
|
||||||
@ -97,7 +93,7 @@ function Update-Config-Var {
|
|||||||
Write-Host "added"
|
Write-Host "added"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Add-Content -Path $ConfigPath -Value "$VarName=$VarValue"
|
Add-Content -Path $ConfigPath -Value "$VarName=$VarValue"
|
||||||
Write-Host "added at the end"
|
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 {
|
function Prepare-Zbx-Agent-Config {
|
||||||
Write-Host "** Preparing Zabbix agent 2 configuration file"
|
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=""
|
$env:ZBX_PASSIVESERVERS=""
|
||||||
}
|
}
|
||||||
else {
|
if ($env:ZBX_ACTIVESERVERS -eq $null) {
|
||||||
$env:ZBX_PASSIVESERVERS=",$env:ZBX_PASSIVESERVERS"
|
|
||||||
}
|
|
||||||
|
|
||||||
$env:ZBX_PASSIVESERVERS=$env:ZBX_SERVER_HOST + $env:ZBX_PASSIVESERVERS
|
|
||||||
|
|
||||||
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVESERVERS)) {
|
|
||||||
$env:ZBX_ACTIVESERVERS=""
|
$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
|
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_HOST)) {
|
||||||
|
if (![string]::IsNullOrEmpty($env:ZBX_SERVER_PORT) -And $env:ZBX_SERVER_PORT -ne "10051") {
|
||||||
Update-Config-Var $ZbxAgentConfig "LogType" "console"
|
$env:ZBX_SERVER_HOST="$env:ZBX_SERVER_HOST:$env:ZBX_SERVER_PORT"
|
||||||
Update-Config-Var $ZbxAgentConfig "LogFile"
|
}
|
||||||
Update-Config-Var $ZbxAgentConfig "LogFileSize"
|
if (![string]::IsNullOrEmpty($env:ZBX_ACTIVESERVERS)) {
|
||||||
Update-Config-Var $ZbxAgentConfig "DebugLevel" "$env:ZBX_DEBUGLEVEL"
|
$env:ZBX_ACTIVESERVERS="$env:ZBX_SERVER_HOST,$env:ZBX_ACTIVESERVERS"
|
||||||
Update-Config-Var $ZbxAgentConfig "SourceIP"
|
}
|
||||||
|
else {
|
||||||
|
$env:ZBX_ACTIVESERVERS=$env:ZBX_SERVER_HOST
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVE_ALLOW)) {
|
if ([string]::IsNullOrWhitespace($env:ZBX_PASSIVE_ALLOW)) {
|
||||||
$env:ZBX_PASSIVE_ALLOW="true"
|
$env:ZBX_PASSIVE_ALLOW="true"
|
||||||
@ -160,14 +180,11 @@ function Prepare-Zbx-Agent-Config {
|
|||||||
Update-Config-Var $ZbxAgentConfig "Server"
|
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)) {
|
if ([string]::IsNullOrWhitespace($env:ZBX_ACTIVE_ALLOW)) {
|
||||||
$env:ZBX_ACTIVE_ALLOW="true"
|
$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"
|
Write-Host "** Using '$env:ZBX_ACTIVESERVERS' servers for active checks"
|
||||||
Update-Config-Var $ZbxAgentConfig "ServerActive" "$env:ZBX_ACTIVESERVERS"
|
Update-Config-Var $ZbxAgentConfig "ServerActive" "$env:ZBX_ACTIVESERVERS"
|
||||||
}
|
}
|
||||||
@ -175,13 +192,22 @@ function Prepare-Zbx-Agent-Config {
|
|||||||
Update-Config-Var $ZbxAgentConfig "ServerActive"
|
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"
|
||||||
|
|
||||||
if ([string]::IsNullOrWhitespace($env:ZBX_ENABLEPERSISTENTBUFFER)) {
|
if ([string]::IsNullOrWhitespace($env:ZBX_ENABLEPERSISTENTBUFFER)) {
|
||||||
$env:ZBX_ENABLEPERSISTENTBUFFER="true"
|
$env:ZBX_ENABLEPERSISTENTBUFFER="true"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($env:ZBX_ENABLEPERSISTENTBUFFER -eq "true") {
|
if ($env:ZBX_ENABLEPERSISTENTBUFFER -eq "true") {
|
||||||
Update-Config-Var $ZbxAgentConfig "EnablePersistentBuffer" "1"
|
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"
|
Update-Config-Var $ZbxAgentConfig "PersistentBufferPeriod" "$env:ZBX_PERSISTENTBUFFERPERIOD"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -214,23 +240,35 @@ function Prepare-Zbx-Agent-Config {
|
|||||||
Update-Config-Var $ZbxAgentConfig "UnsafeUserParameters" "$env:ZBX_UNSAFEUSERPARAMETERS"
|
Update-Config-Var $ZbxAgentConfig "UnsafeUserParameters" "$env:ZBX_UNSAFEUSERPARAMETERS"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSConnect" "$env:ZBX_TLSCONNECT"
|
Update-Config-Var $ZbxAgentConfig "TLSConnect" "$env:ZBX_TLSCONNECT"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSAccept" "$env:ZBX_TLSACCEPT"
|
Update-Config-Var $ZbxAgentConfig "TLSAccept" "$env:ZBX_TLSACCEPT"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE"
|
File-Process-From-Env $ZbxAgentConfig "TLSCAFile" "$env:ZBX_TLSCAFILE" "$env:ZBX_TLSCA"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSCRLFile" "$env:ZBX_TLSCRLFILE"
|
File-Process-From-Env $ZbxAgentConfig "TLSCRLFile" "$env:ZBX_TLSCRLFILE" "$env:ZBX_TLSCRL"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSServerCertIssuer" "$env:ZBX_TLSSERVERCERTISSUER"
|
Update-Config-Var $ZbxAgentConfig "TLSServerCertIssuer" "$env:ZBX_TLSSERVERCERTISSUER"
|
||||||
Update-Config-Var $ZbxAgentConfig "TLSServerCertSubject" "$env:ZBX_TLSSERVERCERTSUBJECT"
|
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 "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 "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 "DenyKey" "$env:ZBX_DENYKEY"
|
||||||
Update-Config-Multiple-Var $ZbxAgentConfig "AllowKey" "$env:ZBX_ALLOWKEY"
|
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 {
|
function PrepareAgent {
|
||||||
Write-Host "** Preparing Zabbix agent 2"
|
Write-Host "** Preparing Zabbix agent 2"
|
||||||
Prepare-Zbx-Agent-Config
|
Prepare-Zbx-Agent-Config
|
||||||
|
ClearZbxEnv
|
||||||
}
|
}
|
||||||
|
|
||||||
$commandArgs=$args
|
$commandArgs=$args
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
# escape=`
|
# escape=`
|
||||||
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
|
ARG OS_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
|
||||||
FROM $BUILD_BASE_IMAGE AS builder_base
|
FROM ${OS_BASE_IMAGE}
|
||||||
|
|
||||||
|
ARG GIT_VERSION=2.47.1
|
||||||
|
ARG NASM_VERSION=2.16.03
|
||||||
|
ARG VS_BUILDTOOLS_VERSION=17
|
||||||
|
|
||||||
ARG PCRE_VERSION=8.45
|
ARG PCRE_VERSION=8.45
|
||||||
ARG OPENSSL_VERSION=1.1.1s
|
ARG OPENSSL_VERSION=1.1.1w
|
||||||
ARG ZLIB_VERSION=1.3.1
|
ARG ZLIB_VERSION=1.3.1
|
||||||
ARG CURL_VERSION=8.7.1
|
ARG CURL_VERSION=8.11.1
|
||||||
|
|
||||||
ARG BUILD_ARCH=x64
|
ARG BUILD_ARCH=x64
|
||||||
ARG CPU_MODEL=AMD64
|
|
||||||
|
|
||||||
ARG MAJOR_VERSION=5.0
|
ARG MAJOR_VERSION=5.0
|
||||||
ARG ZBX_VERSION=${MAJOR_VERSION}.45
|
ARG ZBX_VERSION=${MAJOR_VERSION}.45
|
||||||
|
|
||||||
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 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_53822_64bit/strawberry-perl-5.38.2.2-64bit-portable.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 VS_BUILDTOOLS_URL=https://aka.ms/vs/$VS_BUILDTOOLS_VERSION/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 NASM_URL=https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/win64/nasm-$NASM_VERSION-installer-x64.exe
|
||||||
|
|
||||||
ARG PCRE_URL=https://sourceforge.net/projects/pcre/files/pcre/$PCRE_VERSION/pcre-$PCRE_VERSION.zip
|
ARG PCRE_URL=https://sourceforge.net/projects/pcre/files/pcre/$PCRE_VERSION/pcre-$PCRE_VERSION.zip
|
||||||
ARG OPENSSL_URL=https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
|
ARG OPENSSL_URL=https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
|
||||||
@ -26,9 +29,9 @@ ARG ZLIB_URL=https://zlib.net/zlib-$ZLIB_VERSION.tar.gz
|
|||||||
ARG CURL_URL=https://curl.se/download/curl-$CURL_VERSION.tar.gz
|
ARG CURL_URL=https://curl.se/download/curl-$CURL_VERSION.tar.gz
|
||||||
|
|
||||||
ENV ZBX_VERSION=$ZBX_VERSION `
|
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 `
|
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 `
|
||||||
PCRE_VERSION=$PCRE_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
|
PCRE_VERSION=$PCRE_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
|
||||||
PCRE_URL=$PCRE_URL OPENSSL_URL=$OPENSSL_URL `
|
PCRE_URL=$PCRE_URL OPENSSL_URL=$OPENSSL_URL `
|
||||||
ZLIB_URL=$ZLIB_URL CURL_URL=$CURL_URL
|
ZLIB_URL=$ZLIB_URL CURL_URL=$CURL_URL
|
||||||
@ -42,6 +45,13 @@ 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.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
|
||||||
org.opencontainers.image.version="${ZBX_VERSION}"
|
org.opencontainers.image.version="${ZBX_VERSION}"
|
||||||
|
|
||||||
|
ADD --checksum=sha256:5b709aa45ea3b8bb73052947200ad187f651a2049158fb5bbfed329e4322a977 $PCRE_URL C:\pcre.zip
|
||||||
|
ADD --checksum=sha256:cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8 $OPENSSL_URL C:\openssl.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';"]
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
|
|
||||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||||
@ -55,10 +65,13 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
|
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
|
||||||
[Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); `
|
[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); `
|
Write-Host ('Downloading {0} ...' -f $env:GIT_URL); `
|
||||||
Invoke-WebRequest -OutFile $env:TEMP\git.zip -Uri $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; `
|
$d_sha256 = (Get-FileHash $env:TEMP\git.zip -Algorithm sha256).Hash; `
|
||||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||||
if ($d_sha256 -ne $sha256) { `
|
if ($d_sha256 -ne $sha256) { `
|
||||||
@ -80,7 +93,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
Write-Host ('Downloading {0} ...' -f $env:PERL_URL); `
|
Write-Host ('Downloading {0} ...' -f $env:PERL_URL); `
|
||||||
Invoke-WebRequest -OutFile $env:TEMP\perl.zip -Uri $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; `
|
$d_sha256 = (Get-FileHash $env:TEMP\perl.zip -Algorithm sha256).Hash; `
|
||||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||||
if ($d_sha256 -ne $sha256) { `
|
if ($d_sha256 -ne $sha256) { `
|
||||||
@ -120,9 +133,9 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
--norestart `
|
--norestart `
|
||||||
--nocache `
|
--nocache `
|
||||||
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" `
|
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" `
|
||||||
--channelUri https://aka.ms/vs/17/release/channel `
|
--channelUri https://aka.ms/vs/$env:VS_BUILDTOOLS_VERSION/release/channel `
|
||||||
--installChannelUri https://aka.ms/vs/17/release/channel `
|
--installChannelUri https://aka.ms/vs/$env:VS_BUILDTOOLS_VERSION/release/channel `
|
||||||
--channelId VisualStudio.17.Release `
|
--channelId VisualStudio.$env:VS_BUILDTOOLS_VERSION.Release `
|
||||||
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
|
# 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.Windows11SDK.22621 `
|
||||||
--add Microsoft.VisualStudio.Component.VC.CMake.Project; `
|
--add Microsoft.VisualStudio.Component.VC.CMake.Project; `
|
||||||
@ -138,76 +151,25 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
Write-Host 'Visual Studio components installation cleanup'; `
|
Write-Host 'Visual Studio components installation cleanup'; `
|
||||||
Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; `
|
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...'; `
|
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; `
|
Set-Location -Path $env:BUILD_SRC; `
|
||||||
`
|
`
|
||||||
Write-Host ('Downloading {0} ...' -f $env:PCRE_URL); `
|
|
||||||
Invoke-WebRequest -UserAgent 'Wget' -Uri $env:PCRE_URL -OutFile $env:TEMP\pcre.zip; `
|
|
||||||
`
|
|
||||||
$sha256 = '5B709AA45EA3B8BB73052947200AD187F651A2049158FB5BBFED329E4322A977'; `
|
|
||||||
$d_sha256 = (Get-FileHash $env:TEMP\pcre.zip -Algorithm sha256).Hash; `
|
|
||||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
|
||||||
if ($d_sha256 -ne $sha256) { `
|
|
||||||
Write-Host ('Checksum PCRE 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 = 'C5AC01E760EE6FF0DAB61D6B2BBD30146724D063EB322180C6F18A6F74E4B6AA'; `
|
|
||||||
$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: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 = 'F91249C87F68EA00CF27C44FDFA5A78423E41E71B7D408E5901A9896D905C495'; `
|
|
||||||
$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 PCRE archive ...'; `
|
Write-Host 'Extracting PCRE archive ...'; `
|
||||||
Expand-Archive -Path $env:TEMP\pcre.zip -DestinationPath $env:BUILD_SRC; `
|
Expand-Archive -Path $env:SystemDrive\pcre.zip -DestinationPath $env:BUILD_SRC; `
|
||||||
Rename-Item -Path $env:BUILD_SRC\pcre-$env:PCRE_VERSION -NewName $env:BUILD_SRC\pcre; `
|
Rename-Item -Path $env:BUILD_SRC\pcre-$env:PCRE2_VERSION -NewName $env:BUILD_SRC\pcre; `
|
||||||
New-Item -ItemType directory -Path "$env:BUILD_SRC\pcre\build" | Out-Null; `
|
New-Item -ItemType directory -Path "$env:BUILD_SRC\pcre\build" | Out-Null; `
|
||||||
`
|
`
|
||||||
Write-Host 'Extracting OpenSSL archive ...'; `
|
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; `
|
Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; `
|
||||||
`
|
`
|
||||||
Write-Host 'Extracting Zlib archive ...'; `
|
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; `
|
Move-Item -Path $env:BUILD_SRC\zlib-$env:ZLIB_VERSION\ -Destination $env:BUILD_SRC\zlib; `
|
||||||
`
|
`
|
||||||
Write-Host 'Extracting CURL archive ...'; `
|
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; `
|
Move-Item -Path $env:BUILD_SRC\curl-$env:CURL_VERSION\ -Destination $env:BUILD_SRC\curl; `
|
||||||
`
|
`
|
||||||
Set-Location -Path $env:SystemDrive\.; `
|
Set-Location -Path $env:SystemDrive\.; `
|
||||||
@ -276,7 +238,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
set CL=/MP; `
|
set CL=/MP; `
|
||||||
nmake /S -f Makefile.vc `
|
nmake /S -f Makefile.vc `
|
||||||
mode=static `
|
mode=static `
|
||||||
VC=17 `
|
VC=$env:VS_BUILDTOOLS_VERSION `
|
||||||
DEBUG=no `
|
DEBUG=no `
|
||||||
CC="""cl.exe /DCURL_DISABLE_LDAP /DCURL_DISABLE_LDAPS""" `
|
CC="""cl.exe /DCURL_DISABLE_LDAP /DCURL_DISABLE_LDAPS""" `
|
||||||
MACHINE=$env:BUILD_ARCH `
|
MACHINE=$env:BUILD_ARCH `
|
||||||
@ -290,7 +252,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
ZLIB_PATH=$env:BUILD_OUTPUT\zlib `
|
ZLIB_PATH=$env:BUILD_OUTPUT\zlib `
|
||||||
RTLIBCFG=static; `
|
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; `
|
Remove-Item -Path $env:BUILD_SRC\curl\builds\* -Force -Recurse; `
|
||||||
Write-Host 'Curl is ready...'; `
|
Write-Host 'Curl is ready...'; `
|
||||||
`
|
`
|
||||||
|
@ -1,38 +1,33 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
# escape=`
|
# escape=`
|
||||||
ARG BUILD_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
|
ARG OS_BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022
|
||||||
FROM $BUILD_BASE_IMAGE AS builder_base
|
FROM ${OS_BASE_IMAGE}
|
||||||
|
|
||||||
ARG PCRE_VERSION=8.45
|
ARG PCRE_VERSION=8.45
|
||||||
ARG OPENSSL_VERSION=1.1.1s
|
ARG OPENSSL_VERSION=1.1.1w
|
||||||
ARG GOLANG_VERSION=1.18.8
|
ARG GOLANG_VERSION=1.23.2
|
||||||
ARG SEVEN_ZIP_VERSION=2405
|
ARG VS_BUILDTOOLS_VERSION=17
|
||||||
|
|
||||||
ARG MSYSTEM=MINGW64
|
ARG MSYSTEM=MINGW64
|
||||||
|
|
||||||
ARG BUILD_ARCH=x64
|
ARG BUILD_ARCH=x64
|
||||||
ARG CPU_MODEL=AMD64
|
|
||||||
|
|
||||||
ARG MAJOR_VERSION=5.0
|
ARG MAJOR_VERSION=5.0
|
||||||
ARG ZBX_VERSION=${MAJOR_VERSION}.45
|
ARG ZBX_VERSION=${MAJOR_VERSION}.45
|
||||||
|
|
||||||
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 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 SEVEN_ZIP_URL=https://www.7-zip.org/a/7z$SEVEN_ZIP_VERSION-$BUILD_ARCH.msi
|
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/$VS_BUILDTOOLS_VERSION/release/vs_buildtools.exe
|
||||||
|
|
||||||
ARG MINGW_URL=https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-win32/sjlj/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0.7z
|
|
||||||
ARG VS_BUILDTOOLS_URL=https://aka.ms/vs/17/release/vs_buildtools.exe
|
|
||||||
ARG GOLANG_URL=https://go.dev/dl/go$GOLANG_VERSION.windows-amd64.zip
|
ARG 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 MSYS2_URL=https://api.github.com/repos/msys2/msys2-installer/releases/latest
|
||||||
|
|
||||||
ARG PCRE_URL=https://sourceforge.net/projects/pcre/files/pcre/$PCRE_VERSION/pcre-$PCRE_VERSION.zip
|
ARG PCRE_URL=https://sourceforge.net/projects/pcre/files/pcre/$PCRE_VERSION/pcre-$PCRE_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 `
|
ENV ZBX_VERSION=$ZBX_VERSION `
|
||||||
BUILD_ARCH=$BUILD_ARCH CPU_MODEL=$CPU_MODEL `
|
BUILD_ARCH=$BUILD_ARCH `
|
||||||
GIT_URL=$GIT_URL SEVEN_ZIP_VERSION=$SEVEN_ZIP_VERSION `
|
MINGW_URL=$MINGW_URL VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL VS_BUILDTOOLS_VERSION=$VS_BUILDTOOLS_VERSION GOLANG_VERSION=$GOLANG_VERSION MSYS2_URL=$MSYS2_URL `
|
||||||
MINGW_URL=$MINGW_URL VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL GOLANG_VERSION=$GOLANG_VERSION MSYS2_URL=$MSYS2_URL `
|
PCRE2_VERSION=$PCRE2_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
|
||||||
PCRE_VERSION=$PCRE_VERSION OPENSSL_VERSION=$OPENSSL_VERSION `
|
PCRE2_URL=$PCRE2_URL OPENSSL_URL=$OPENSSL_URL `
|
||||||
PCRE_URL=$PCRE_URL OPENSSL_URL=$OPENSSL_URL `
|
|
||||||
CHERE_INVOKING=yes MSYSTEM=$MSYSTEM
|
CHERE_INVOKING=yes MSYSTEM=$MSYSTEM
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
|
LABEL org.opencontainers.image.title="Zabbix agent 2 build base for Windows" `
|
||||||
@ -44,13 +39,15 @@ 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.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
|
||||||
org.opencontainers.image.version="${ZBX_VERSION}"
|
org.opencontainers.image.version="${ZBX_VERSION}"
|
||||||
|
|
||||||
|
ADD --checksum=sha256:5b709aa45ea3b8bb73052947200ad187f651a2049158fb5bbfed329e4322a977 $PCRE_URL C:\pcre.zip
|
||||||
|
ADD --checksum=sha256:cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8 $OPENSSL_URL C:\openssl.tar.gz
|
||||||
|
|
||||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
|
|
||||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; `
|
||||||
`
|
`
|
||||||
$env:PATH = [string]::Format('{0}\mingw64\bin;{0}\go\bin;{0}\git\cmd;{0}\git\mingw64\bin;{0}\git\usr\bin;{1}\7-Zip;', $env:SystemDrive, ${env:ProgramFiles}) + $env:PATH; `
|
$env:PATH = $env:PATH + [string]::Format(';{0}\mingw64\bin;{0}\go\bin;{0}\msys64\usr\bin;{0}\msys64\{1}\bin', $env:SystemDrive, $env:MSYSTEM.ToLower()); `
|
||||||
$env:PATH = $env:PATH + [string]::Format(';{0}\msys64\usr\bin;{0}\msys64\{1}\bin', $env:SystemDrive, $env:MSYSTEM.ToLower()); `
|
|
||||||
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
|
||||||
`
|
`
|
||||||
$env:BUILD_OUTPUT = [string]::Format('{0}\build_output', $env:SystemDrive); `
|
$env:BUILD_OUTPUT = [string]::Format('{0}\build_output', $env:SystemDrive); `
|
||||||
@ -58,32 +55,13 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
|
$env:BUILD_SRC = [string]::Format('{0}\build_src', $env:SystemDrive); `
|
||||||
[Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); `
|
[Environment]::SetEnvironmentVariable('BUILD_SRC', $env:BUILD_SRC, [EnvironmentVariableTarget]::Machine); `
|
||||||
`
|
`
|
||||||
Write-Host ('Downloading {0} ...' -f $env:GIT_URL); `
|
New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; `
|
||||||
Invoke-WebRequest -OutFile $env:TEMP\git.zip -Uri $env:GIT_URL; `
|
New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; `
|
||||||
`
|
|
||||||
$sha256 = '273f55e881094d00877d64f56570b0c997c4da5dedcb26738d56481033c1eba1'; `
|
|
||||||
$d_sha256 = (Get-FileHash $env:TEMP\git.zip -Algorithm sha256).Hash; `
|
|
||||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
|
||||||
if ($d_sha256 -ne $sha256) { `
|
|
||||||
Write-Host ('Checksum GIT for Windows ({0}) failed!' -f $d_sha256); `
|
|
||||||
exit 1; `
|
|
||||||
}; `
|
|
||||||
`
|
|
||||||
Write-Host ('Downloading {0} ...' -f $env:SEVEN_ZIP_URL); `
|
|
||||||
Invoke-WebRequest -OutFile $env:TEMP\7z.msi -Uri $env:SEVEN_ZIP_URL; `
|
|
||||||
`
|
|
||||||
$sha256 = '0F6AA6596D418B1694F62C8583DE05D24589B8D7FFACCE5A7DAB52AE71F832B6'; `
|
|
||||||
$d_sha256 = (Get-FileHash $env:TEMP\7z.msi -Algorithm sha256).Hash; `
|
|
||||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
|
||||||
if ($d_sha256 -ne $sha256) { `
|
|
||||||
Write-Host ('Checksum 7-zip ({0}) failed!' -f $d_sha256); `
|
|
||||||
exit 1; `
|
|
||||||
}; `
|
|
||||||
`
|
`
|
||||||
Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); `
|
Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); `
|
||||||
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
|
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
|
||||||
`
|
`
|
||||||
$sha256 = '980788761e75ed33ffc4f2a7a3ff07cd90949bd023eb1a8d855ef0b5de9cbcba'; `
|
$sha256 = 'bc28fe3002cd65cec65d0e4f6000584dacb8c71bfaff8801dfb532855ca42513'; `
|
||||||
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
|
$d_sha256 = (Get-FileHash $env:TEMP\go_lang.zip -Algorithm sha256).Hash; `
|
||||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
||||||
if ($d_sha256 -ne $sha256) { `
|
if ($d_sha256 -ne $sha256) { `
|
||||||
@ -91,17 +69,6 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
exit 1; `
|
exit 1; `
|
||||||
}; `
|
}; `
|
||||||
`
|
`
|
||||||
Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); `
|
|
||||||
Invoke-WebRequest -UserAgent 'Wget' -Uri $env:MINGW_URL -OutFile $env:TEMP\mingw.7z; `
|
|
||||||
`
|
|
||||||
$sha256 = 'e8c65ddc655534b0330f66f7b480565621e8617cda9937d76ba141a22bf3b2fa'; `
|
|
||||||
$d_sha256 = (Get-FileHash $env:TEMP\mingw.7z -Algorithm sha256).Hash; `
|
|
||||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
|
||||||
if ($d_sha256 -ne $sha256) { `
|
|
||||||
Write-Host ('Checksum Mingw-w64 ({0}) failed!' -f $d_sha256); `
|
|
||||||
exit 1; `
|
|
||||||
}; `
|
|
||||||
`
|
|
||||||
Write-Host ('Downloading {0} ...' -f $env:MSYS2_URL); `
|
Write-Host ('Downloading {0} ...' -f $env:MSYS2_URL); `
|
||||||
Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $(Invoke-RestMethod -UseBasicParsing $env:MSYS2_URL | `
|
Invoke-WebRequest -OutFile $env:TEMP\msys2.sfx.exe -Uri $(Invoke-RestMethod -UseBasicParsing $env:MSYS2_URL | `
|
||||||
Select -ExpandProperty "assets" | `
|
Select -ExpandProperty "assets" | `
|
||||||
@ -116,45 +83,31 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
# exit 1; `
|
# exit 1; `
|
||||||
}; `
|
}; `
|
||||||
`
|
`
|
||||||
|
Write-Host ('Downloading {0} ...' -f $env:MINGW_URL); `
|
||||||
|
Invoke-WebRequest -OutFile $env:TEMP\mingw.7z -Uri $env:MINGW_URL; `
|
||||||
|
`
|
||||||
|
$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) { `
|
||||||
|
Write-Host ('Checksum Mingw-w64 ({0}) failed!' -f $d_sha256); `
|
||||||
|
exit 1; `
|
||||||
|
}; `
|
||||||
|
`
|
||||||
Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); `
|
Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); `
|
||||||
Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; `
|
Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; `
|
||||||
`
|
`
|
||||||
Write-Host 'Installing GIT...'; `
|
|
||||||
Expand-Archive `
|
|
||||||
-Path $env:TEMP\git.zip `
|
|
||||||
-DestinationPath $env:SystemDrive\git\.; `
|
|
||||||
Write-Host 'Removing downloaded...'; `
|
|
||||||
`
|
|
||||||
Write-Host 'Verifying install ("git version") ...'; `
|
|
||||||
git version; `
|
|
||||||
`
|
|
||||||
Write-Host 'Installing 7z...'; `
|
|
||||||
Start-Process `
|
|
||||||
-FilePath $env:TEMP\7z.msi `
|
|
||||||
-Wait `
|
|
||||||
-ArgumentList '/qn /norestart'; `
|
|
||||||
`
|
|
||||||
Write-Host 'Verifying install ("7z -h") ...'; `
|
|
||||||
7z -h | Select -first 2; `
|
|
||||||
`
|
|
||||||
Write-Host 'Installing Go Lang...'; `
|
Write-Host 'Installing Go Lang...'; `
|
||||||
Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; `
|
Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; `
|
||||||
`
|
`
|
||||||
Write-Host 'Verifying install ("go version") ...'; `
|
Write-Host 'Verifying install ("go version") ...'; `
|
||||||
go version; `
|
go version; `
|
||||||
`
|
`
|
||||||
Write-Host 'Installing Mingw-w64...'; `
|
|
||||||
7z x $env:TEMP\mingw.7z; `
|
|
||||||
compact /c /i /s:$env:SystemDrive\mingw64 | Out-Null; `
|
|
||||||
`
|
|
||||||
Write-Host 'Verifying install ("gcc -v") ...'; `
|
|
||||||
gcc -v; `
|
|
||||||
`
|
|
||||||
Write-Host 'Installing MSYS2...'; `
|
Write-Host 'Installing MSYS2...'; `
|
||||||
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
|
& $env:TEMP\msys2.sfx.exe -y -o"""$env:SystemDrive\""" | Out-Null; `
|
||||||
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
|
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
|
||||||
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
|
bash -lc 'pacman --noprogressbar --noconfirm -Syuu'; `
|
||||||
bash -lc 'pacman --noprogressbar --sync --quiet --noconfirm mingw-w64-x86_64-cmake'; `
|
bash -lc 'pacman --noprogressbar --sync --quiet --noconfirm mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-7zip git'; `
|
||||||
bash -lc 'pacman --noprogressbar --noconfirm -Scc'; `
|
bash -lc 'pacman --noprogressbar --noconfirm -Scc'; `
|
||||||
bash -lc 'rm -rf /usr/share/man/* /usr/share/doc/* /usr/share/locale/*'; `
|
bash -lc 'rm -rf /usr/share/man/* /usr/share/doc/* /usr/share/locale/*'; `
|
||||||
bash -lc 'rm -rf /$MSYSTEM/usr/share/man/* /$MSYSTEM/usr/share/doc/* /$MSYSTEM/usr/share/locale/*'; `
|
bash -lc 'rm -rf /$MSYSTEM/usr/share/man/* /$MSYSTEM/usr/share/doc/* /$MSYSTEM/usr/share/locale/*'; `
|
||||||
@ -166,6 +119,13 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
Write-Host 'Verifying install ("bash --version") ...'; `
|
Write-Host 'Verifying install ("bash --version") ...'; `
|
||||||
bash --version; `
|
bash --version; `
|
||||||
`
|
`
|
||||||
|
Write-Host 'Installing Mingw-w64...'; `
|
||||||
|
7z x $env:TEMP\mingw.7z; `
|
||||||
|
compact /c /i /s:$env:SystemDrive\mingw64 | Out-Null; `
|
||||||
|
`
|
||||||
|
Write-Host 'Verifying install ("gcc -v") ...'; `
|
||||||
|
gcc -v; `
|
||||||
|
`
|
||||||
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
|
Write-Host ('{0} - Visual Studio components installing...' -f $(Get-Date -format 'u')); `
|
||||||
cmd /C start /w $env:TEMP\vs_buildtools.exe `
|
cmd /C start /w $env:TEMP\vs_buildtools.exe `
|
||||||
--quiet `
|
--quiet `
|
||||||
@ -173,9 +133,9 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
--norestart `
|
--norestart `
|
||||||
--nocache `
|
--nocache `
|
||||||
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" `
|
--installPath """${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools""" `
|
||||||
--channelUri https://aka.ms/vs/17/release/channel `
|
--channelUri https://aka.ms/vs/$env:VS_BUILDTOOLS_VERSION/release/channel `
|
||||||
--installChannelUri https://aka.ms/vs/17/release/channel `
|
--installChannelUri https://aka.ms/vs/$env:VS_BUILDTOOLS_VERSION/release/channel `
|
||||||
--channelId VisualStudio.17.Release `
|
--channelId VisualStudio.$env:VS_BUILDTOOLS_VERSION.Release `
|
||||||
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022
|
# 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; `
|
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64; `
|
||||||
if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { `
|
if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { `
|
||||||
@ -190,51 +150,17 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
Write-Host 'Visual Studio components installation cleanup'; `
|
Write-Host 'Visual Studio components installation cleanup'; `
|
||||||
Get-ChildItem -Path """${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer""" -Directory -Recurse | Remove-Item -Force -Recurse; `
|
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...'; `
|
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; `
|
Set-Location -Path $env:BUILD_SRC; `
|
||||||
`
|
`
|
||||||
Write-Host ('Downloading {0} ...' -f $env:PCRE_URL); `
|
|
||||||
Invoke-WebRequest -UserAgent 'Wget' -Uri $env:PCRE_URL -OutFile $env:TEMP\pcre.zip; `
|
|
||||||
`
|
|
||||||
$sha256 = '5B709AA45EA3B8BB73052947200AD187F651A2049158FB5BBFED329E4322A977'; `
|
|
||||||
$d_sha256 = (Get-FileHash $env:TEMP\pcre.zip -Algorithm sha256).Hash; `
|
|
||||||
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
|
|
||||||
if ($d_sha256 -ne $sha256) { `
|
|
||||||
Write-Host ('Checksum PCRE 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 = 'C5AC01E760EE6FF0DAB61D6B2BBD30146724D063EB322180C6F18A6F74E4B6AA'; `
|
|
||||||
$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 PCRE archive ...'; `
|
Write-Host 'Extracting PCRE archive ...'; `
|
||||||
Expand-Archive -Path $env:TEMP\pcre.zip -DestinationPath $env:BUILD_SRC; `
|
Expand-Archive -Path $env:SystemDrive\pcre.zip -DestinationPath $env:BUILD_SRC; `
|
||||||
`
|
Rename-Item -Path $env:BUILD_SRC\pcre-$env:PCRE2_VERSION -NewName $env:BUILD_SRC\pcre; `
|
||||||
Write-Host 'Removing downloaded ...'; `
|
|
||||||
Remove-Item -Force -Path $env:TEMP\pcre.zip; `
|
|
||||||
Rename-Item -Path $env:BUILD_SRC\pcre-$env:PCRE_VERSION -NewName $env:BUILD_SRC\pcre; `
|
|
||||||
`
|
`
|
||||||
Write-Host 'Extracting OpenSSL archive ...'; `
|
Write-Host 'Extracting OpenSSL archive ...'; `
|
||||||
$env:SystemDirectory = [Environment]::SystemDirectory; `
|
$env:SystemDirectory = [Environment]::SystemDirectory; `
|
||||||
tar -zxf "$env:TEMP\openssl.tar.gz"; `
|
tar -zxf "$env:SystemDrive\openssl.tar.gz"; `
|
||||||
`
|
|
||||||
Write-Host 'Removing downloaded...'; `
|
|
||||||
Remove-Item -Force -Path $env:TEMP\openssl.tar.gz; `
|
|
||||||
Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; `
|
Rename-Item -Path $env:BUILD_SRC\openssl-$env:OPENSSL_VERSION -NewName $env:BUILD_SRC\openssl; `
|
||||||
`
|
`
|
||||||
Write-Host 'Building PCRE library ...'; `
|
Write-Host 'Building PCRE library ...'; `
|
||||||
|
@ -6,13 +6,12 @@ ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent-${ZBX_VERSION}
|
|||||||
|
|
||||||
FROM ${BUILD_BASE_IMAGE} AS builder
|
FROM ${BUILD_BASE_IMAGE} AS builder
|
||||||
|
|
||||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
|
||||||
|
|
||||||
ARG MAJOR_VERSION
|
ARG MAJOR_VERSION
|
||||||
ARG ZBX_VERSION
|
ARG ZBX_VERSION
|
||||||
|
ARG ZABBIX_VERSION_RC_NUM=2400
|
||||||
|
|
||||||
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
||||||
ARG GIT_BRANCH
|
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} `
|
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 `
|
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); `
|
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; `
|
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; `
|
Set-Location -Path $env:ZBX_SOURCES_DIR; `
|
||||||
$ZbxRevision=(git rev-parse --short HEAD); `
|
$ZbxRevision=(git rev-parse --short HEAD); `
|
||||||
(Get-Content include/version.h).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content include/version.h; `
|
(Get-Content include/version.h).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content include/version.h; `
|
||||||
@ -69,4 +68,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_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\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; `
|
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...';
|
Write-Host 'Zabbix binaries are compiled...';
|
||||||
|
@ -6,11 +6,10 @@ 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
|
||||||
|
ARG ZBX_VERSION
|
||||||
ARG MAJOR_VERSION=5.0
|
|
||||||
ARG ZBX_VERSION=${MAJOR_VERSION}.45
|
|
||||||
ARG ZABBIX_VERSION_RC_NUM=2400
|
ARG ZABBIX_VERSION_RC_NUM=2400
|
||||||
|
|
||||||
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
||||||
ARG GIT_BRANCH
|
ARG GIT_BRANCH
|
||||||
|
|
||||||
@ -28,6 +27,8 @@ LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
|
|||||||
org.opencontainers.image.version="${ZBX_VERSION}" `
|
org.opencontainers.image.version="${ZBX_VERSION}" `
|
||||||
org.opencontainers.image.source="${ZBX_SOURCES}"
|
org.opencontainers.image.source="${ZBX_SOURCES}"
|
||||||
|
|
||||||
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
|
|
||||||
RUN Set-Location -Path $env:SystemDrive\.; `
|
RUN Set-Location -Path $env:SystemDrive\.; `
|
||||||
`
|
`
|
||||||
New-Item -ItemType directory -Path $env:ZBX_SOURCES_DIR | Out-Null; `
|
New-Item -ItemType directory -Path $env:ZBX_SOURCES_DIR | Out-Null; `
|
||||||
@ -42,7 +43,7 @@ RUN Set-Location -Path $env:SystemDrive\.; `
|
|||||||
Write-Host ('Checkout GIT {0} ({1}) repository ...' -f $env:ZBX_SOURCES, $env:GIT_BRANCH); `
|
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; `
|
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; `
|
Set-Location -Path $env:ZBX_SOURCES_DIR; `
|
||||||
$ZbxRevision=(git rev-parse --short HEAD); `
|
$ZbxRevision=(git rev-parse --short HEAD); `
|
||||||
(Get-Content include\version.h).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content include\version.h; `
|
(Get-Content include\version.h).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content include\version.h; `
|
||||||
|
Loading…
Reference in New Issue
Block a user