From 913420af753e49696b4e4245df34c1f8db49e786 Mon Sep 17 00:00:00 2001 From: Robert Schumann Date: Sat, 31 Mar 2018 22:42:24 +0200 Subject: [PATCH] move to other root dir --- Dockerfile | 8 ++--- README.md | 31 +++++++++++++++++-- manifest/entrypoint.sh | 4 +++ manifest/etc/cron.d/root | 2 +- .../dmarcts-report-viewer-config.php | 0 5 files changed, 38 insertions(+), 7 deletions(-) rename manifest/var/www/{html => viewer}/dmarcts-report-viewer-config.php (100%) diff --git a/Dockerfile b/Dockerfile index b615b1e..a1144fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,9 +12,8 @@ RUN set -x \ && wget -q --no-check-certificate -O parser.zip $REPORT_PARSER_SOURCE \ && wget -q --no-check-certificate -O viewer.zip $REPORT_VIEWER_SOURCE \ && unzip parser.zip && cp -v dmarcts-report-parser-master/* /usr/bin/ && rm -f parser.zip \ - && unzip viewer.zip && cp -v dmarcts-report-viewer-master/* /var/www/html/ && rm -f viewer.zip \ - && rm -f /var/www/html/index.php \ - && sed -i "1s/^/body { font-family: Sans-Serif; }\n/" /var/www/html/default.css \ + && unzip viewer.zip && mv dmarcts-report-viewer-master /var/www/viewer && rm -f viewer.zip \ + && sed -i "1s/^/body { font-family: Sans-Serif; }\n/" /var/www/viewer/default.css \ && (echo y;echo o conf prerequisites_policy follow;echo o conf commit)|cpan \ && for i in \ IO::Compress::Gzip \ @@ -34,7 +33,8 @@ RUN set -x \ PerlIO::gzip \ IO::Socket::SSL \ ; do cpan install $i; done \ - && sed -i 's/.*index index.php index.html index.htm;/index dmarcts-report-viewer.php;/g' /etc/nginx/conf.d/default.conf \ + && sed -i 's%.*root /var/www/html;% root /var/www/viewer;%g' /etc/nginx/conf.d/default.conf \ + && sed -i 's/.*index index.php index.html index.htm;/ index dmarcts-report-viewer.php;/g' /etc/nginx/conf.d/default.conf \ && chmod 755 /entrypoint.sh EXPOSE 443 80 diff --git a/README.md b/README.md index c256664..b0143f2 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,14 @@ # docker-dmarc-report [![Docker Pulls](https://img.shields.io/docker/pulls/gutmensch/dmarc-report.svg)](https://registry.hub.docker.com/u/gutmensch/dmarc-report/) -This image is intended to combine a dmarc report parser (see https://github.com/techsneeze/dmarcts-report-parser by TechSneeze.com and John Bieling) with a report viewer (see https://github.com/techsneeze/dmarcts-report-viewer/ by the same people) into a runnable docker image / microservice. It fetches dmarc report mails regularly from an IMAP server, stores them into a MySQL DB, deletes them from IMAP and show them via Webserver/PHP module. +This image is intended to combine a dmarc report parser (see https://github.com/techsneeze/dmarcts-report-parser by TechSneeze.com and John Bieling) with a report viewer (see https://github.com/techsneeze/dmarcts-report-viewer/ by the same people) into a runnable docker image / microservice. -## Usage +It fetches dmarc report mails regularly from an IMAP server, stores them into a MySQL DB and visualizes them via Webserver/PHP module. + +## Howto +1. Create a _dmarc.example.com TXT DNS record for your domain, containg a mail address (IMAP postbox) +2. Create a MySQL Database and a user for this service +3. Run this docker image with below mentioned env vars +4. Access port 80 on the container (or 443) or put it behind a reverse proxy to view reports ``` docker pull gutmensch/dmarc-report docker run -ti gutmensch/dmarc-report @@ -12,3 +18,24 @@ docker run -ti gutmensch/dmarc-report dmarcts report viewer: 2018-03-31 dmarcts report parser: 2018-03-31 +## Sample docker compose / Environment variables +``` +dmarc-report: + image: "gutmensch/dmarc-report:latest" + hostname: dmarc-report + container_name: dmarc-report + environment: + - "TEMPLATE_NGINX_HTML=1" + - "TEMPLATE_PERL_CONF=1" + - "REPORT_DB_HOST=mysql" + - "REPORT_DB_NAME=dmarc_report" + - "REPORT_DB_USER=dmarc_report" + - "REPORT_DB_PASS=foobar" + - "PARSER_IMAP_SERVER_WITH_PORT=mail:143" + - "PARSER_IMAP_USER=foobar@example.com + - "PARSER_IMAP_PASS=foobar" + - "PARSER_IMAP_READ_FOLDER=Inbox" + - "PARSER_IMAP_MOVE_FOLDER=processed" + - "PARSER_PROCESS_INTERVAL=@hourly" +``` + diff --git a/manifest/entrypoint.sh b/manifest/entrypoint.sh index 60c3fb0..d155eb2 100644 --- a/manifest/entrypoint.sh +++ b/manifest/entrypoint.sh @@ -39,6 +39,10 @@ if [[ -v TEMPLATE_PERL_CONF ]] ; then done fi +if [[ -v PARSER_PROCESS_INTERVAL ]] ; then + echo "${PARSER_PROCESS_INTERVAL} /usr/bin/dmarcts-report-parser.pl -i -d -r" > /etc/cron.d/root +fi + # Start supervisord and services /usr/bin/supervisord -n -c /etc/supervisord.conf diff --git a/manifest/etc/cron.d/root b/manifest/etc/cron.d/root index f695d57..19177da 100644 --- a/manifest/etc/cron.d/root +++ b/manifest/etc/cron.d/root @@ -1 +1 @@ -*/5 * * * * /usr/bin/dmarcts-report-parser.pl -i -d -r +@hourly /usr/bin/dmarcts-report-parser.pl -i -d -r diff --git a/manifest/var/www/html/dmarcts-report-viewer-config.php b/manifest/var/www/viewer/dmarcts-report-viewer-config.php similarity index 100% rename from manifest/var/www/html/dmarcts-report-viewer-config.php rename to manifest/var/www/viewer/dmarcts-report-viewer-config.php