2021-09-17 22:35:50 +02:00
|
|
|
# syntax=docker/dockerfile:1
|
|
|
|
# escape=`
|
2022-07-05 14:46:20 +02:00
|
|
|
ARG MAJOR_VERSION=6.4
|
2024-11-20 08:42:05 +01:00
|
|
|
ARG ZBX_VERSION=${MAJOR_VERSION}.20
|
2021-09-17 22:35:50 +02:00
|
|
|
ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent2-${ZBX_VERSION}
|
|
|
|
|
|
|
|
FROM ${BUILD_BASE_IMAGE} as builder
|
|
|
|
|
|
|
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
|
|
|
|
2022-07-05 14:46:20 +02:00
|
|
|
ARG MAJOR_VERSION=6.4
|
2024-11-20 08:42:05 +01:00
|
|
|
ARG ZBX_VERSION=${MAJOR_VERSION}.20
|
2021-09-17 22:35:50 +02:00
|
|
|
ARG ZABBIX_VERSION_RC_NUM=2400
|
|
|
|
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
2024-05-21 09:53:13 +02:00
|
|
|
ARG MONGODB_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mongodb.git
|
|
|
|
ARG POSTGRESQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/postgresql.git
|
2024-06-01 08:10:31 +02:00
|
|
|
ARG MSSQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mssql.git
|
2024-05-21 09:53:13 +02:00
|
|
|
ARG GIT_BRANCH
|
|
|
|
|
2024-07-31 05:20:41 +02:00
|
|
|
ARG ZBX_PLUGINS_VERSION=${GIT_BRANCH:-$ZBX_VERSION}
|
|
|
|
|
2024-05-21 09:53:13 +02:00
|
|
|
ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION ZBX_VERSION=$ZBX_VERSION GIT_BRANCH=${GIT_BRANCH:-$ZBX_VERSION} `
|
2024-07-31 05:20:41 +02:00
|
|
|
MONGODB_PLUGIN_SOURCES=$MONGODB_PLUGIN_SOURCES MONGODB_PLUGIN_VERSION=${ZBX_PLUGINS_VERSION} `
|
|
|
|
POSTGRESQL_PLUGIN_SOURCES=$POSTGRESQL_PLUGIN_SOURCES POSTGRESQL_PLUGIN_VERSION=${ZBX_PLUGINS_VERSION} `
|
|
|
|
MSSQL_PLUGIN_SOURCES=$MSSQL_PLUGIN_SOURCES MSSQL_PLUGIN_VERSION=${ZBX_PLUGINS_VERSION} `
|
2024-06-01 08:10:31 +02:00
|
|
|
ZABBIX_VERSION_RC_NUM=$ZABBIX_VERSION_RC_NUM `
|
|
|
|
ZBX_SOURCES_DIR=C:\\zabbix-${ZBX_VERSION} ZBX_OUTPUT_DIR=C:\\zabbix-${ZBX_VERSION}-output
|
2021-09-17 22:35:50 +02:00
|
|
|
|
2021-09-18 03:08:26 +02:00
|
|
|
LABEL org.opencontainers.image.title="Zabbix agent 2 build (Windows)" `
|
|
|
|
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
2024-05-21 12:45:53 +02:00
|
|
|
org.opencontainers.image.vendor="Zabbix SIA" `
|
2021-09-18 03:08:26 +02:00
|
|
|
org.opencontainers.image.url="https://zabbix.com/" `
|
|
|
|
org.opencontainers.image.description="Zabbix build for agent 2 images based on Windows" `
|
|
|
|
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}" `
|
2021-09-17 22:35:50 +02:00
|
|
|
org.opencontainers.image.source="${ZBX_SOURCES}"
|
|
|
|
|
|
|
|
RUN Set-Location -Path $env:SystemDrive\.; `
|
|
|
|
`
|
2024-06-01 08:10:31 +02:00
|
|
|
New-Item -ItemType directory -Path $env:ZBX_SOURCES_DIR | Out-Null; `
|
|
|
|
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR | Out-Null; `
|
|
|
|
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\sbin | Out-Null; `
|
|
|
|
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\conf | Out-Null; `
|
|
|
|
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\conf\zabbix_agentd.d | Out-Null; `
|
|
|
|
New-Item -ItemType directory -Path $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin | Out-Null; `
|
2024-05-21 09:53:13 +02:00
|
|
|
`
|
|
|
|
Import-Module (Get-ChildItem $env:VS_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName; `
|
|
|
|
Enter-VsDevShell -VsInstallPath $env:VS_PATH -SkipAutomaticLocation -DevCmdArguments """-arch=$env:BUILD_ARCH"""; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
2024-05-29 13:12:05 +02:00
|
|
|
Write-Host ('Checkout GIT {0} ({1}) repository ...' -f $env:ZBX_SOURCES, $env:GIT_BRANCH); `
|
2024-06-01 08:10:31 +02:00
|
|
|
git -c advice.detachedHead=false clone $env:ZBX_SOURCES --branch $env:GIT_BRANCH --depth 1 --single-branch $env:ZBX_SOURCES_DIR; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
|
|
|
Write-Host ('Building Zabbix {0} version ...' -f $env:ZBX_VERSION); `
|
2024-06-01 08:10:31 +02:00
|
|
|
Set-Location -Path $env:ZBX_SOURCES_DIR; `
|
2021-09-17 22:35:50 +02:00
|
|
|
$ZbxRevision=(git rev-parse --short HEAD); `
|
2024-05-21 09:53:13 +02:00
|
|
|
(Get-Content include\version.h).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content include\version.h; `
|
2021-09-17 22:35:50 +02:00
|
|
|
(Get-Content src\go\pkg\version\version.go).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content src\go\pkg\version\version.go; `
|
2024-06-01 08:10:31 +02:00
|
|
|
Set-Location -Path $env:ZBX_SOURCES_DIR\build\mingw; `
|
2024-05-21 09:53:13 +02:00
|
|
|
mingw32-make -j"""$env:NUMBER_OF_PROCESSORS""" `
|
|
|
|
PCRE2=$env:BUILD_OUTPUT\pcre2 `
|
|
|
|
OPENSSL=$env:BUILD_OUTPUT\openssl `
|
2021-09-17 22:35:50 +02:00
|
|
|
RFLAGS="""-DZABBIX_VERSION_RC_NUM=$env:ZABBIX_VERSION_RC_NUM"""; `
|
|
|
|
`
|
|
|
|
Write-Host 'Verifying build ("zabbix_agent2.exe -V") ...'; `
|
2024-06-01 08:10:31 +02:00
|
|
|
& $env:ZBX_SOURCES_DIR\bin\win64\zabbix_agent2.exe -V; `
|
|
|
|
dumpbin /dependents $env:ZBX_SOURCES_DIR\bin\win64\zabbix_agent2.exe; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
2024-06-01 08:10:31 +02:00
|
|
|
Copy-Item -Path $env:ZBX_SOURCES_DIR\bin\win64\zabbix_agent2.exe $env:ZBX_OUTPUT_DIR\sbin; `
|
|
|
|
Copy-Item -Path $env:ZBX_SOURCES_DIR\src\go\conf\zabbix_agent2.win.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.conf; `
|
2024-06-01 10:44:03 +02:00
|
|
|
Copy-Item -Recurse -Path $env:ZBX_SOURCES_DIR\src\go\conf\zabbix_agent2.d $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d; `
|
2024-05-21 09:53:13 +02:00
|
|
|
mingw32-make -s clean; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
2022-12-15 05:54:48 +01:00
|
|
|
Write-Host ('Building Zabbix MongoDB plugin {0} version ...' -f $env:MONGODB_PLUGIN_VERSION); `
|
2024-06-01 08:10:31 +02:00
|
|
|
git -c advice.detachedHead=false clone $env:MONGODB_PLUGIN_SOURCES --branch $env:MONGODB_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION; `
|
|
|
|
Set-Location -Path $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION; `
|
2022-12-15 05:54:48 +01:00
|
|
|
mingw32-make; `
|
|
|
|
`
|
2024-05-21 09:53:13 +02:00
|
|
|
Write-Host 'Verifying MongoDB plugin ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
|
2024-06-01 08:10:31 +02:00
|
|
|
& $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION\zabbix-agent2-plugin-mongodb.exe -V; `
|
2024-05-21 09:53:13 +02:00
|
|
|
`
|
2024-06-01 08:10:31 +02:00
|
|
|
Copy-Item -Path $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION\zabbix-agent2-plugin-mongodb.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\mongodb.exe; `
|
2024-06-01 10:44:03 +02:00
|
|
|
Copy-Item -Path $env:SystemDrive\mongodb-plugin-$env:MONGODB_PLUGIN_VERSION\mongodb.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.d; `
|
2024-05-21 09:53:13 +02:00
|
|
|
mingw32-make -s clean; `
|
|
|
|
`
|
2022-12-15 05:54:48 +01:00
|
|
|
Write-Host ('Building Zabbix PostgreSQL plugin {0} version ...' -f $env:POSTGRESQL_PLUGIN_VERSION); `
|
2024-06-01 08:10:31 +02:00
|
|
|
git -c advice.detachedHead=false clone $env:POSTGRESQL_PLUGIN_SOURCES --branch $env:POSTGRESQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION; `
|
|
|
|
Set-Location -Path $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION; `
|
2022-12-15 05:54:48 +01:00
|
|
|
mingw32-make; `
|
2024-05-21 09:53:13 +02:00
|
|
|
`
|
2022-12-15 05:54:48 +01:00
|
|
|
Write-Host 'Verifying build ("zabbix-agent2-plugin-postgresql.exe -V") ...'; `
|
2024-06-01 08:10:31 +02:00
|
|
|
& $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION\zabbix-agent2-plugin-postgresql.exe -V; `
|
2024-05-21 09:53:13 +02:00
|
|
|
`
|
2024-06-01 08:10:31 +02:00
|
|
|
Copy-Item -Path $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION\zabbix-agent2-plugin-postgresql.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\postgresql.exe; `
|
2024-06-01 10:44:03 +02:00
|
|
|
Copy-Item -Path $env:SystemDrive\postgresql-plugin-$env:POSTGRESQL_PLUGIN_VERSION\postgresql.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.d; `
|
2024-06-01 08:10:31 +02:00
|
|
|
mingw32-make -s clean; `
|
|
|
|
`
|
|
|
|
Write-Host ('Building Zabbix MSSQL plugin {0} version ...' -f $env:MSSQL_PLUGIN_VERSION); `
|
|
|
|
git -c advice.detachedHead=false clone $env:MSSQL_PLUGIN_SOURCES --branch $env:MSSQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION; `
|
|
|
|
Set-Location -Path $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION; `
|
|
|
|
mingw32-make; `
|
|
|
|
`
|
|
|
|
Write-Host 'Verifying MSSQL plugin ("zabbix-agent2-plugin-mssql.exe -V") ...'; `
|
|
|
|
& $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION\zabbix-agent2-plugin-mssql.exe -V; `
|
|
|
|
`
|
|
|
|
Copy-Item -Path $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION\zabbix-agent2-plugin-mssql.exe $env:ZBX_OUTPUT_DIR\zabbix-agent2-plugin\mssql.exe; `
|
2024-06-01 10:44:03 +02:00
|
|
|
Copy-Item -Path $env:SystemDrive\mssql-plugin-$env:MSSQL_PLUGIN_VERSION\mssql.conf $env:ZBX_OUTPUT_DIR\conf\zabbix_agent2.d\plugins.d; `
|
2024-06-01 08:10:31 +02:00
|
|
|
mingw32-make -s clean; `
|
|
|
|
`
|
2024-05-21 09:53:13 +02:00
|
|
|
Write-Host 'Zabbix binaries are compiled...';
|