Skip to content

Instantly share code, notes, and snippets.

@maxried
Last active September 29, 2020 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxried/f513e9ced24545a9009dd2cd760dce58 to your computer and use it in GitHub Desktop.
Save maxried/f513e9ced24545a9009dd2cd760dce58 to your computer and use it in GitHub Desktop.
Compile latest Zabbix for Debian from the Repositories using Docker

If you need to compile your own deb packages for Zabbix, this gist may help you.

My motivation was that there are no official repositories for Debian ARM. If you run Debian on your Raspbery Pi and want to have an up to date Zabbix Agent or Proxy, the official Zabbix repositories won't be of much help. Either you install the 32 bit version Raspbian version, which might come with broken dependencies on your geniune Debian installation, or you use the ancient Zabbix version from the official Debian repositories. Unfortunately you have to have Docker installed to run this, but I didn't want to clutter the storage on my Raspberry Pi. It runs for about 75 minutes on my Raspberry Pi, but then you should have packages you can install using dpkg, and apt. Should work on other platforms, too.

On my Raspberry Pi 3 B, building the Dockerfile took about 18 minutes. Running the Dockerfile to create the packages takes about 75 minutes.

docker image build --tag compile-zabbix:latest https://git.io/Jf0Om
docker container run -itv "/srv/zabbix-packages:/output" --rm compile-zabbix:latest

After it has finished, you can install the packages that are now stored in /srv/zabbix-packages. E.g. you can run the following to install zabbix_agent2.

apt install /srv/zabbix-packages/zabbix-agent2_5.0.0-1+buster_arm64.deb
FROM debian:buster-slim AS zabbix-builder
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /tmp/zabbix-build-environment
ADD https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1+buster_all.deb /tmp/repository.deb
RUN dpkg --install /tmp/repository.deb
RUN echo "deb http://deb.debian.org/debian buster-backports main" > /etc/apt/sources.list.d/backports.list
RUN apt-get update
RUN apt-get --assume-yes install dpkg-dev devscripts
# Golang has to installed from backports, because the Debian stable golang is too old, and won't build Agent2.
# It's also not included in the Zabbix build-deps, so we have to install it manually.
RUN apt-get --assume-yes --target-release buster-backports install golang
# To fix a problem with the jdk package, which is a build dependency
RUN mkdir --parents /usr/share/man/man1
RUN apt-get --assume-yes build-dep zabbix
RUN printf '#!/bin/sh\napt-get update\napt-get source zabbix\ncd $(find . -maxdepth 1 -mindepth 1 -type d -name "zabbix-*");\ndebuild -b -uc -us -j4\ncd ..\nmv *.deb /output/' > /build.sh ; chmod +x /build.sh
VOLUME [ "/output" ]
CMD [ "/build.sh" ]
FROM ubuntu:20.04 AS zabbix-builder
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /tmp/zabbix-build-environment
ADD https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb /tmp/repository.deb
RUN dpkg --install /tmp/repository.deb
RUN apt-get update
# golang is not included in the Zabbix build-deps, so we have to install it manually.
RUN apt-get --assume-yes install dpkg-dev devscripts golang
RUN apt-get --assume-yes build-dep zabbix
RUN printf '#!/bin/sh\napt-get update\napt-get source zabbix\ncd $(find . -maxdepth 1 -mindepth 1 -type d -name "zabbix-*");\ndebuild -b -uc -us -j4\ncd ..\nmv *.deb /output/' > /build.sh ; chmod +x /build.sh
VOLUME [ "/output" ]
CMD [ "/build.sh" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment