diff --git a/data/Dockerfiles/dovecot/Dockerfile b/data/Dockerfiles/dovecot/Dockerfile index 1d3bfbef..aa3ed9da 100644 --- a/data/Dockerfiles/dovecot/Dockerfile +++ b/data/Dockerfiles/dovecot/Dockerfile @@ -20,6 +20,7 @@ RUN apt-get update \ automake \ syslog-ng \ syslog-ng-core \ + syslog-ng-mod-redis \ ca-certificates \ supervisor \ wget \ @@ -64,20 +65,20 @@ RUN wget https://pigeonhole.dovecot.org/releases/2.2/dovecot-2.2-pigeonhole-$PIG && make install \ && make clean -RUN sed -i -E 's/^(\s*)system\(\);/\1unix-stream("\/dev\/log");/' /etc/syslog-ng/syslog-ng.conf RUN cpanm Data::Uniqid Mail::IMAPClient String::Util RUN echo '* * * * * root /usr/local/bin/imapsync_cron.pl' > /etc/cron.d/imapsync RUN echo '30 3 * * * vmail /usr/bin/doveadm quota recalc -A' > /etc/cron.d/dovecot-sync -COPY ./imapsync /usr/local/bin/imapsync -COPY ./postlogin.sh /usr/local/bin/postlogin.sh -COPY ./imapsync_cron.pl /usr/local/bin/imapsync_cron.pl -COPY ./report-spam.sieve /usr/local/lib/dovecot/sieve/report-spam.sieve -COPY ./report-ham.sieve /usr/local/lib/dovecot/sieve/report-ham.sieve -COPY ./rspamd-pipe-ham /usr/local/lib/dovecot/sieve/rspamd-pipe-ham -COPY ./rspamd-pipe-spam /usr/local/lib/dovecot/sieve/rspamd-pipe-spam -COPY ./docker-entrypoint.sh / -COPY ./supervisord.conf /etc/supervisor/supervisord.conf +COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf +COPY imapsync /usr/local/bin/imapsync +COPY postlogin.sh /usr/local/bin/postlogin.sh +COPY imapsync_cron.pl /usr/local/bin/imapsync_cron.pl +COPY report-spam.sieve /usr/local/lib/dovecot/sieve/report-spam.sieve +COPY report-ham.sieve /usr/local/lib/dovecot/sieve/report-ham.sieve +COPY rspamd-pipe-ham /usr/local/lib/dovecot/sieve/rspamd-pipe-ham +COPY rspamd-pipe-spam /usr/local/lib/dovecot/sieve/rspamd-pipe-spam +COPY docker-entrypoint.sh / +COPY supervisord.conf /etc/supervisor/supervisord.conf RUN chmod +x /usr/local/lib/dovecot/sieve/rspamd-pipe-ham \ /usr/local/lib/dovecot/sieve/rspamd-pipe-spam \ @@ -92,6 +93,8 @@ RUN groupadd -g 5000 vmail \ && useradd -c "Dovecot unprivileged user" -d /dev/null -u 401 -g dovecot -s /bin/false dovecot \ && useradd -c "Dovecot login user" -d /dev/null -u 402 -g dovenull -s /bin/false dovenull +RUN touch /etc/default/locale + EXPOSE 24 10001 ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/data/Dockerfiles/dovecot/supervisord.conf b/data/Dockerfiles/dovecot/supervisord.conf index e5a66f22..e2e02250 100644 --- a/data/Dockerfiles/dovecot/supervisord.conf +++ b/data/Dockerfiles/dovecot/supervisord.conf @@ -12,7 +12,7 @@ command=/usr/local/sbin/dovecot -F autorestart=true [program:logfiles] -command=/usr/bin/tail -f /var/log/mail.log /var/log/syslog +command=/usr/bin/tail -f /var/log/combined.log stdout_logfile=/dev/fd/1 stdout_logfile_maxbytes=0 diff --git a/data/Dockerfiles/dovecot/syslog-ng.conf b/data/Dockerfiles/dovecot/syslog-ng.conf new file mode 100644 index 00000000..ead195a5 --- /dev/null +++ b/data/Dockerfiles/dovecot/syslog-ng.conf @@ -0,0 +1,31 @@ +@version: 3.8 +@include "scl.conf" +options { + chain_hostnames(off); + flush_lines(0); + use_dns(no); + use_fqdn(no); + owner("root"); group("adm"); perm(0640); + stats_freq(0); + bad_hostname("^gconfd$"); +}; +source s_src { + unix-stream("/dev/log"); + internal(); +}; + +destination d_combined { file("/var/log/combined.log"); }; +destination d_redis { + redis( + host("redis-mailcow") + port(6379) + command("LPUSH" "DOVECOT_MAILLOG" "$(format-json time=\"$S_UNIXTIME\" priority=\"$PRIORITY\" program=\"$PROGRAM\" message=\"$MESSAGE\")\n") + ); +}; +filter f_mail { facility(mail) and not filter(f_debug); }; +log { + source(s_src); + destination(d_combined); + filter(f_mail); + destination(d_redis); +}; diff --git a/data/Dockerfiles/postfix/Dockerfile b/data/Dockerfiles/postfix/Dockerfile index 210de532..87c40cfb 100644 --- a/data/Dockerfiles/postfix/Dockerfile +++ b/data/Dockerfiles/postfix/Dockerfile @@ -19,6 +19,7 @@ RUN apt-get install -y --no-install-recommends supervisor \ postfix-pcre \ syslog-ng \ syslog-ng-core \ + syslog-ng-mod-redis \ ca-certificates \ gnupg \ python-gpgme \ @@ -29,11 +30,13 @@ RUN apt-get install -y --no-install-recommends supervisor \ RUN addgroup --system --gid 600 zeyple RUN adduser --system --home /var/lib/zeyple --no-create-home --uid 600 --gid 600 --disabled-login zeyple RUN touch /var/log/zeyple.log && chown zeyple: /var/log/zeyple.log -RUN sed -i -E 's/^(\s*)system\(\);/\1unix-stream("\/dev\/log");/' /etc/syslog-ng/syslog-ng.conf + +RUN touch /etc/default/locale COPY zeyple.py /usr/local/bin/zeyple.py COPY zeyple.conf /etc/zeyple.conf COPY supervisord.conf /etc/supervisor/supervisord.conf +COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf COPY postfix.sh /opt/postfix.sh COPY whitelist_forwardinghosts.sh /usr/local/bin/whitelist_forwardinghosts.sh diff --git a/data/Dockerfiles/postfix/supervisord.conf b/data/Dockerfiles/postfix/supervisord.conf index 72523a61..0968bb0a 100644 --- a/data/Dockerfiles/postfix/supervisord.conf +++ b/data/Dockerfiles/postfix/supervisord.conf @@ -12,7 +12,7 @@ command=/opt/postfix.sh autorestart=true [program:postfix-maillog] -command=/bin/tail -f /var/log/zeyple.log /var/log/mail.log +command=/bin/tail -f /var/log/zeyple.log /var/log/combined.log stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 diff --git a/data/Dockerfiles/postfix/syslog-ng.conf b/data/Dockerfiles/postfix/syslog-ng.conf new file mode 100644 index 00000000..2c1fce88 --- /dev/null +++ b/data/Dockerfiles/postfix/syslog-ng.conf @@ -0,0 +1,31 @@ +@version: 3.8 +@include "scl.conf" +options { + chain_hostnames(off); + flush_lines(0); + use_dns(no); + use_fqdn(no); + owner("root"); group("adm"); perm(0640); + stats_freq(0); + bad_hostname("^gconfd$"); +}; +source s_src { + unix-stream("/dev/log"); + internal(); +}; + +destination d_combined { file("/var/log/combined.log"); }; +destination d_redis { + redis( + host("redis-mailcow") + port(6379) + command("LPUSH" "POSTFIX_MAILLOG" "$(format-json time=\"$S_UNIXTIME\" priority=\"$PRIORITY\" program=\"$PROGRAM\" message=\"$MESSAGE\")\n") + ); +}; +filter f_mail { facility(mail) and not filter(f_debug); }; +log { + source(s_src); + destination(d_combined); + filter(f_mail); + destination(d_redis); +};