update base os, cleanup

This commit is contained in:
dave 2021-09-30 23:35:14 -07:00
parent 265856d2d5
commit 3e0fe97f03
2 changed files with 59 additions and 52 deletions

View File

@ -1,90 +1,88 @@
# Using LTS ubuntu FROM ubuntu:focal
FROM ubuntu:14.04
MAINTAINER "Mark Vartanyan <kolypto@gmail.com>"
# Packages: update & install # Packages: update & install
ENV DEBCONF_FRONTEND noninteractive RUN apt-get update -qq && \
RUN sed -i 's~.* universe$~\0 multiverse~' /etc/apt/sources.list DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends python3-pip supervisor build-essential apache2 libapache2-mod-php7.4 snmp-mibs-downloader apache2-utils wget curl samba-common samba-common-bin smbclient snmp whois traceroute libgd-dev libssl-dev libnet-snmp-perl libperl-dev libpq5 libsensors5 libsnmp-base libtalloc2 libtdb1 libwbclient0 libmysqlclient-dev unzip inetutils-ping sudo openssh-client bind9-dnsutils file && \
RUN apt-get update -qq pip3 install j2cli && \
RUN apt-get install -qq -y --no-install-recommends python-pip supervisor build-essential update-alternatives --install /usr/bin/python python $(which python3) 2 # Workaround for nagios scripts wanting python2 as "python"
RUN apt-get install -qq -y --no-install-recommends apache2 libapache2-mod-php5 snmp-mibs-downloader
RUN apt-get install -qq -y --no-install-recommends apache2-utils wget curl samba-common samba-common-bin smbclient snmp whois traceroute
RUN apt-get install -qq -y --no-install-recommends libgd2-xpm-dev libssl-dev libnet-snmp-perl libperl-dev libpq5 libradius1 libsensors4 libsnmp-base libtalloc2 libtdb1 libwbclient0 libmysqlclient15-dev
RUN pip install j2cli
# Const # Const
ENV NAGIOS_PHP_TIMEZONE UTC ENV NAGIOS_PHP_TIMEZONE=UTC \
ENV NAGIOS_TARBALL http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.7.tar.gz NAGIOS_TARBALL=https://phoenixnap.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.4.6/nagios-4.4.6.tar.gz \
ENV NAGIOS_PLUGINS_TARBALL http://www.nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz NAGIOS_PLUGINS_TARBALL=https://www.nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz \
ENV NAGIOS_NRPE_TARBALL http://kent.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz NAGIOS_NRPE_TARBALL=https://phoenixnap.dl.sourceforge.net/project/nagios/nrpe-4.x/nrpe-4.0.3/nrpe-4.0.3.tar.gz \
ENV NAGIOS_NSCA_TARBALL http://prdownloads.sourceforge.net/sourceforge/nagios/nsca-2.7.2.tar.gz NAGIOS_NSCA_TARBALL=https://phoenixnap.dl.sourceforge.net/project/nagios/nsca-2.x/nsca-2.10.0/nsca-2.10.0.tar.gz
# Using manual: https://raymii.org/s/tutorials/Nagios_Core_4_Installation_on_Ubuntu_12.04.html # Using manual: https://raymii.org/s/tutorials/Nagios_Core_4_Installation_on_Ubuntu_12.04.html
#https://kent.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz \
# Users # Users
RUN groupadd -g 3000 nagios RUN groupadd -g 3000 nagios && \
RUN useradd -u 3000 -g nagios -G www-data -m -s /bin/bash nagios useradd -u 3000 -g nagios -G www-data -m -s /bin/bash nagios
# Install nagios # Install nagios
RUN mkdir -p /usr/local/src/nagios4 RUN mkdir -p /usr/local/src/nagios4 && \
RUN cd /usr/local/src/nagios4 && wget $NAGIOS_TARBALL -O- | tar -zxp --strip-components 1 && ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagios && make all && make install install-init install-config install-commandmode cd /usr/local/src/nagios4 && \
RUN ln -s /usr/local/nagios/etc /etc/nagios wget -q $NAGIOS_TARBALL -O- | tar -zxp --strip-components 1 && \
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagios && \
make -j8 all && \
make install install-init install-config install-commandmode && \
ln -s /usr/local/nagios/etc /etc/nagios
# Install nagios plugins # Install nagios plugins
RUN mkdir -p /usr/local/src/nagios4-plugins RUN mkdir -p /usr/local/src/nagios4-plugins && \
RUN cd /usr/local/src/nagios4-plugins && wget $NAGIOS_PLUGINS_TARBALL -O- | tar -zxp --strip-components 1 && ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl=/usr/bin/openssl --enable-perl-modules --enable-libtap && make && make install cd /usr/local/src/nagios4-plugins && \
wget -q $NAGIOS_PLUGINS_TARBALL -O- | tar -zxp --strip-components 1 && \
./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl=/usr/bin/openssl --enable-perl-modules --enable-libtap && \
make -j8 && \
make install
# Install nagios NRPE # Install nagios NRPE
RUN mkdir -p /usr/local/src/nagios4-nrpe RUN mkdir -p /usr/local/src/nagios4-nrpe && \
RUN cd /usr/local/src/nagios4-nrpe && wget $NAGIOS_NRPE_TARBALL -O- | tar -zxp --strip-components 1 && ./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu && make all && make install install-plugin install-daemon install-daemon-config cd /usr/local/src/nagios4-nrpe && \
wget -q $NAGIOS_NRPE_TARBALL -O- | tar -zxp --strip-components 1 && \
./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu && \
make -j8 all && \
make install install-plugin install-daemon install-config
# Install nagios NSCA # Install nagios NSCA
RUN mkdir -p /usr/local/src/nagios4-nsca RUN mkdir -p /usr/local/src/nagios4-nsca && \
RUN cd /usr/local/src/nagios4-nsca && wget $NAGIOS_NSCA_TARBALL -O- | tar -zxp --strip-components 1 && ./configure --with-nsca-user=nagios --with-nsca-grp=nagios && make all cd /usr/local/src/nagios4-nsca && \
RUN cd /usr/local/src/nagios4-nsca && cp sample-config/nsca.cfg sample-config/send_nsca.cfg /etc/nagios/ && cp src/send_nsca src/nsca /usr/local/bin/ wget -q $NAGIOS_NSCA_TARBALL -O- | tar -zxp --strip-components 1 && \
RUN chmod 644 /etc/nagios/nsca.cfg ./configure --with-nsca-user=nagios --with-nsca-grp=nagios && \
make -j8 all && \
cd /usr/local/src/nagios4-nsca && \
cp sample-config/nsca.cfg sample-config/send_nsca.cfg /etc/nagios/ && \
cp src/send_nsca src/nsca /usr/local/bin/ && \
chmod 644 /etc/nagios/nsca.cfg
# Clean-up # Clean-up
RUN rm -rf /usr/local/src/nagios* RUN rm -rf /usr/local/src/nagios*
# Add files # Add files
ADD conf /root/conf ADD conf /root/conf
# Configure: php # Configure: php
RUN j2 /root/conf/php.ini > /etc/php5/mods-available/custom.ini RUN j2 /root/conf/php.ini > /etc/php/7.4/mods-available/custom.ini && \
RUN php5enmod custom phpenmod custom
# Configure: apache # Configure: apache
ADD conf/apache2-site.conf /etc/apache2/sites-available/nagios.conf ADD conf/apache2-site.conf /etc/apache2/sites-available/nagios.conf
RUN a2dissite 000-default RUN a2dissite 000-default && \
RUN a2ensite nagios a2ensite nagios && \
RUN a2enmod cgi a2enmod cgi
# Configure: supervisor # Configure: supervisor
ADD conf/supervisor-all.conf /etc/supervisor/conf.d/ ADD conf/supervisor-all.conf /etc/supervisor/conf.d/
# Configure: nagios # Configure: nagios
RUN bash -c 'mkdir -p /etc/nagios/conf.d /etc/nagios/conf.d/{hosts,services,timeperiods,templates,hostgroups,servicegroups,contacts}' RUN bash -c 'mkdir -p /etc/nagios/conf.d /etc/nagios/conf.d/{hosts,services,timeperiods,templates,hostgroups,servicegroups,contacts}' && \
echo 'cfg_dir=/etc/nagios/conf.d/' >> /etc/nagios/nagios.cfg && \
RUN echo 'cfg_dir=/etc/nagios/conf.d/' >> /etc/nagios/nagios.cfg sed -i 's~^url_html_path=.*~url_html_path=/~' /etc/nagios/cgi.cfg
RUN sed -i 's~^url_html_path=.*~url_html_path=/~' /etc/nagios/cgi.cfg
# Runner # Runner
ADD run.sh /root/run.sh ADD run.sh /root/run.sh
# Declare # Declare
VOLUME ["/etc/nagios/", "/usr/local/nagios/var/"] VOLUME ["/etc/nagios/", "/usr/local/nagios/var/"]
EXPOSE 80 EXPOSE 80
@ -92,4 +90,3 @@ EXPOSE 5666
EXPOSE 5667 EXPOSE 5667
CMD ["/root/run.sh"] CMD ["/root/run.sh"]

10
Makefile Normal file
View File

@ -0,0 +1,10 @@
DOCKERIMAGE := dockermirror:5000/dpedu/nagios-4
DOCKEROPTS :=
.PHONY: image
image:
docker build -t $(DOCKERIMAGE) $(DOCKEROPTS) .
.PHONY: push
push: image
docker push $(DOCKERIMAGE)