zabbix-docker/Dockerfiles/build-mysql/windows/Dockerfile.agent2

81 lines
4.9 KiB
Docker
Raw Normal View History

# syntax=docker/dockerfile:1
# escape=`
2023-03-07 09:07:13 +01:00
ARG MAJOR_VERSION=7.0
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent2-${ZBX_VERSION}
FROM ${BUILD_BASE_IMAGE} as builder
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
2023-03-07 09:07:13 +01:00
ARG MAJOR_VERSION=7.0
2022-02-27 14:57:35 +01:00
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG ZABBIX_VERSION_RC_NUM=2400
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
ARG GIT_BRANCH=master
ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION GIT_BRANCH=${GIT_BRANCH:-$ZBX_VERSION} `
MONGODB_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/mongodb.git MONGODB_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION} `
POSTGRESQL_PLUGIN_SOURCES=https://git.zabbix.com/scm/ap/postgresql.git POSTGRESQL_PLUGIN_VERSION=${GIT_BRANCH:-$ZBX_VERSION}
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-13 19:31:38 +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" `
2024-05-13 19:31:38 +02:00
org.opencontainers.image.licenses="AGPL v3.0" `
2021-09-18 03:08:26 +02:00
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
org.opencontainers.image.version="${ZBX_VERSION}" `
org.opencontainers.image.source="${ZBX_SOURCES}"
RUN Set-Location -Path $env:SystemDrive\.; `
2024-05-13 10:29:45 +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"""; `
`
2024-05-13 10:29:45 +02:00
Write-Host ('Checkout GIT {0} ({1}) repository ...' -f $env:ZBX_SOURCES, $GIT_BRANCH); `
git -c advice.detachedHead=false clone $env:ZBX_SOURCES --branch $GIT_BRANCH --depth 1 --single-branch $env:SystemDrive\zabbix-$env:ZBX_VERSION; `
`
Write-Host ('Building Zabbix {0} version ...' -f $env:ZBX_VERSION); `
Set-Location -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION; `
$ZbxRevision=(git rev-parse --short HEAD); `
(Get-Content src\go\pkg\version\version.go).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content src\go\pkg\version\version.go; `
Set-Location -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\build\mingw; `
mingw32-make -j"""$env:NUMBER_OF_PROCESSORS""" `
CGO_LDFLAGS="""-lcrypt32 -L$env:BUILD_OUTPUT\openssl\lib -L$env:BUILD_OUTPUT\pcre2\lib""" `
PCRE2=$env:BUILD_OUTPUT\pcre2 `
OPENSSL=$env:BUILD_OUTPUT\openssl `
RFLAGS="""-DZABBIX_VERSION_RC_NUM=2400"""; `
`
Write-Host 'Verifying build ("zabbix_agent2.exe -V") ...'; `
& $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe -V; `
dumpbin /dependents $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe; `
`
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2 | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2\sbin | Out-Null; `
New-Item -ItemType directory -Path $env:SystemDrive\zabbix2\conf | Out-Null; `
`
Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agent2.exe $env:SystemDrive\zabbix2\sbin; `
Copy-Item -Path $env:SystemDrive\zabbix-$env:ZBX_VERSION\src\go\conf\zabbix_agent2.win.conf $env:SystemDrive\zabbix2\conf; `
mingw32-make -s clean; `
2022-12-15 05:54:48 +01:00
`
Set-Location -Path $env:SystemDrive; `
Write-Host ('Building Zabbix MongoDB plugin {0} version ...' -f $env:MONGODB_PLUGIN_VERSION); `
2024-05-13 10:29:45 +02:00
git -c advice.detachedHead=false clone $env:MONGODB_PLUGIN_SOURCES --branch $MONGODB_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\mongodb_plugin; `
2022-12-15 05:54:48 +01:00
Set-Location -Path $env:SystemDrive\mongodb_plugin; `
mingw32-make; `
2023-05-29 05:44:35 +02:00
mv $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe; `
2022-12-15 05:54:48 +01:00
Write-Host 'Verifying build ("zabbix-agent2-plugin-mongodb.exe -V") ...'; `
& $env:SystemDrive\mongodb_plugin\zabbix-agent2-plugin-mongodb.exe -V; `
`
Set-Location -Path $env:SystemDrive; `
Write-Host ('Building Zabbix PostgreSQL plugin {0} version ...' -f $env:POSTGRESQL_PLUGIN_VERSION); `
2024-05-13 10:29:45 +02:00
git -c advice.detachedHead=false clone $env:POSTGRESQL_PLUGIN_SOURCES --branch $POSTGRESQL_PLUGIN_VERSION --depth 1 --single-branch $env:SystemDrive\postgresql_plugin; `
2022-12-15 05:54:48 +01:00
Set-Location -Path $env:SystemDrive\postgresql_plugin; `
mingw32-make; `
2023-05-29 05:44:35 +02:00
mv $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe; `
2022-12-15 05:54:48 +01:00
Write-Host 'Verifying build ("zabbix-agent2-plugin-postgresql.exe -V") ...'; `
& $env:SystemDrive\postgresql_plugin\zabbix-agent2-plugin-postgresql.exe -V; `
Remove-Item -Recurse -Force -Path $(go env GOCACHE); `
Write-Host 'Zabbix binaries are compiled...';