summaryrefslogtreecommitdiffstats
path: root/Dockerfile
blob: cf26e499025a21e8ea610e1454e0ae2a65d11988 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
FROM alpine:latest

MAINTAINER Suren Chilingaryan <csa@suren.me>

ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.8/supercronic-linux-amd64 \
    SUPERCRONIC=supercronic-linux-amd64 \
    SUPERCRONIC_SHA1SUM=be43e64c45acd6ec4fce5831e03759c89676a0ea

VOLUME /munin/db
#Only small temporary files, doesn't need volume
#VOLUME /var/lib/nginx

RUN  packages="munin nginx wget heirloom-mailx patch spawn-fcgi perl-cgi-fast curl busybox-extras font-adobe-75dpi"; \
    apk update && apk upgrade && apk add --no-cache $packages \
 && curl -fsSLO "$SUPERCRONIC_URL" \
 && echo "${SUPERCRONIC_SHA1SUM}  ${SUPERCRONIC}" | sha1sum -c - \
 && chmod +x "$SUPERCRONIC" \
 && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
 && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic

ADD ./munin.conf /etc/munin/munin.conf
ADD ./nginx.conf /etc/nginx/nginx.conf
ADD ./nginx-munin /etc/nginx/sites-enabled/munin
ADD ./start-munin.sh /munin.sh
ADD ./patches /patches

# rsyslog is not actually used, but I keep here configuration just in case
# Nginx always creates error_log in /var/log/nginx, but doesn't write there if other locating is configured
RUN \
    #sed -i -e 's|^$FileOwner|#$FileOwner|' "/etc/rsyslog.conf" && \
    #sed -i -e 's|^$FileGroup|#$FileGroup|' "/etc/rsyslog.conf" && \
    #sed -i -e 's|^$PrivDrop|#$PrivDrop|' "/etc/rsyslog.conf" && \
    #sed -i -e 's|^$ModLoad imuxsock|#$ModLoad imuxsock|' "/etc/rsyslog.conf" && \
    #sed -i -e 's|^$ModLoad imklog|#$ModLoad imklog|' "/etc/rsyslog.conf" && \
    \
    rm -rf /var/log/nginx && \
    ln -s /tmp /var/log/nginx && \
    ln -s /tmp /var/lib/nginx/logs && \
    rm -f /etc/nginx/conf.d/default.conf && \
    rm -f /etc/nginx/sites-enabled/default && \
    \
    ln -s /usr/share/webapps/munin/cgi /usr/lib/munin/cgi && \
    cd /usr/lib/munin && patch munin-graph < /patches/munin-graph-logging.patch && patch munin-update < /patches/munin-update-logging.patch && \
    cd /usr/share/perl5/vendor_perl/Munin/Master/ && patch Update.pm < /patches/munin-ds-datalock.patch && \
    sed -re "/@[[:alnum:]]+/ d; s|munin if|if|" /etc/munin/munin.cron.sample > /etc/munin/munin.cron && \
    \
    bash -c "mkdir -p /munin/{db,log,www/cache}" && \
    ln -s ../www/cache /munin/db/cgi-tmp && \
    rm -rf /var/lib/munin/cgi-tmp && \
    ln -s /munin/www/cache /var/lib/munin/cgi-tmp && \
    \
    chgrp -R root /munin /var/run/munin /etc/munin/munin.conf /var/tmp/nginx /var/lib/nginx && \
    chmod -R g+rw /munin /var/run/munin /etc/munin/munin.conf /var/tmp/nginx  && \
    for name in "/var/tmp/nginx /munin/"; do find $name -type d -print0 | xargs -0 chmod g+x; done

EXPOSE 8080
CMD ["bash", "/munin.sh"]