zabbix-docker/snmptraps/ubuntu/Dockerfile

95 lines
3.6 KiB
Docker
Raw Normal View History

FROM ubuntu:bionic
2018-02-18 21:42:44 +01:00
ARG MAJOR_VERSION=master
ARG ZBX_VERSION=${MAJOR_VERSION}
2019-05-10 16:11:07 +02:00
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
2018-02-18 21:42:44 +01:00
2020-04-28 18:39:39 +02:00
ENV TERM=xterm ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \
MIBDIRS=/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL
LABEL org.opencontainers.image.title="zabbix-snmptraps-ubuntu" \
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" \
org.opencontainers.image.vendor="Zabbix LLC" \
org.opencontainers.image.url="https://zabbix.com/" \
org.opencontainers.image.description="Zabbix SNMP traps receiver" \
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}" \
org.opencontainers.image.source="https://anonscm.debian.org/gitweb/?p=collab-maint/snmptrapfmt.git"
2018-02-18 21:42:44 +01:00
STOPSIGNAL SIGTERM
2016-08-03 14:23:39 +02:00
2020-04-28 18:39:39 +02:00
COPY ["snmptrapfmt_1.14+nmu1ubuntu2.tar.gz", "/tmp/"]
2019-05-30 20:21:16 +02:00
RUN set -eux && \
2016-08-03 14:23:39 +02:00
echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
2020-04-28 18:39:39 +02:00
addgroup --system --gid 1995 --quiet zabbix && \
2016-08-03 14:23:39 +02:00
adduser --quiet \
--system --disabled-login \
2020-04-28 18:39:39 +02:00
--ingroup zabbix --ingroup root \
--uid 1997 \
2016-08-03 14:23:39 +02:00
--home /var/lib/zabbix/ \
zabbix && \
2020-04-28 18:39:39 +02:00
apt-get -y update && \
DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \
2018-02-18 21:42:44 +01:00
snmp-mibs-downloader \
2019-04-18 22:18:57 +02:00
snmptrapd \
supervisor && \
download-mibs && \
2020-04-28 18:39:39 +02:00
DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \
autoconf \
automake \
gcc \
patch \
make \
libc6-dev \
libsnmp-dev && \
2016-08-03 14:23:39 +02:00
mkdir -p /var/lib/zabbix && \
mkdir -p /var/lib/zabbix/snmptraps && \
mkdir -p /var/lib/zabbix/mibs && \
2020-04-28 18:39:39 +02:00
cd /tmp/ && \
tar -zxvf snmptrapfmt_1.14+nmu1ubuntu2.tar.gz && \
ls -lah && \
cd /tmp/snmptrapfmt-1.14+nmu1ubuntu1/ && \
patch -p1 < ./patches/makefile.patch && \
patch -p1 < ./patches/pid_location.patch && \
make -j"$(nproc)" -s && \
cp snmptrapfmthdlr /usr/sbin/snmptrapfmthdlr && \
cp snmptrapfmt /usr/sbin/snmptrapfmt && \
cp snmptrapfmt.conf /etc/snmp/snmptrapfmt.conf && \
2016-08-03 14:23:39 +02:00
echo "disableAuthorization yes" >> "/etc/snmp/snmptrapd.conf" && \
echo "traphandle default /usr/sbin/snmptrapfmthdlr" >> "/etc/snmp/snmptrapd.conf" && \
sed -i \
-e "/^VARFMT=/s/=.*/=\"%n %v \"/" \
-e '/^LOGFMT=/s/=.*/=\"$x ZBXTRAP $R $G $S $e $*\"/' \
-e "/^LOGFILE=/s/=.*/=\"\/var\/lib\/zabbix\/snmptraps\/snmptraps.log\"/" \
"/etc/snmp/snmptrapfmt.conf" && \
2020-04-28 18:39:39 +02:00
rm -rf /tmp/snmptrapfmt_1.14+nmu1ubuntu2.tar.gz && \
rm -rf /tmp/snmptrapfmt-1.14+nmu1ubuntu1/ && \
chown --quiet -R zabbix:root /etc/snmp/ /var/lib/zabbix/ /var/tmp/ /var/run/ && \
chgrp -R 0 /etc/snmp/ /var/lib/zabbix/ /var/tmp/ /var/run/ && \
chmod -R g=u /etc/snmp/ /var/lib/zabbix/ /var/tmp/ /var/run/ && \
DEBIAN_FRONTEND=noninteractive apt-get -y purge \
autoconf \
automake \
gcc \
patch \
make \
libc6-dev \
libsnmp-dev && \
apt-get -y autoremove && \
2016-08-03 14:23:39 +02:00
rm -rf /var/lib/apt/lists/*
2020-04-30 02:28:06 +02:00
EXPOSE 1162/UDP
2016-08-03 14:23:39 +02:00
WORKDIR /var/lib/zabbix/snmptraps/
VOLUME ["/var/lib/zabbix/snmptraps", "/var/lib/zabbix/mibs"]
2016-08-03 14:23:39 +02:00
2018-02-18 21:42:44 +01:00
COPY ["conf/etc/supervisor/", "/etc/supervisor/"]
COPY ["conf/etc/logrotate.d/zabbix_snmptraps", "/etc/logrotate.d/"]
2016-08-03 14:23:39 +02:00
2020-04-28 18:39:39 +02:00
USER 1997
2016-08-03 14:23:39 +02:00
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]