public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Dovecot] Add new imapsync + dependencies [Dovecot] Syslog-ng: Do not trim after each push to Redis [Dovecot] Add new cronjob to trim all Redis logs every minute (will be moved in the future)
04b43d0a
data/Dockerfiles/dovecot/Dockerfile | 10 +++++++++-
data/Dockerfiles/dovecot/docker-entrypoint.sh | 3 ++-
data/Dockerfiles/dovecot/syslog-ng.conf | 9 ---------
data/Dockerfiles/dovecot/trim_logs.sh | 7 +++++++
4 files changed, 18 insertions(+), 11 deletions(-)
create mode 100755 data/Dockerfiles/dovecot/trim_logs.sh
Diff
diff --git a/data/Dockerfiles/dovecot/Dockerfile b/data/Dockerfiles/dovecot/Dockerfile
index 71f194c2..03323914 100644
--- a/data/Dockerfiles/dovecot/Dockerfile
+++ b/data/Dockerfiles/dovecot/Dockerfile
@@ -54,6 +54,10 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
libtry-tiny-perl \
libunicode-string-perl \
libproc-processtable-perl \
+ libtest-nowarnings-perl \
+ libtest-deep-perl \
+ libtest-warn-perl \
+ libregexp-common-perl \
liburi-perl \
lzma-dev \
make \
@@ -61,6 +65,7 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
procps \
supervisor \
cron \
+ redis-server \
syslog-ng \
syslog-ng-core \
syslog-ng-mod-redis \
@@ -85,7 +90,9 @@ RUN curl https://www.dovecot.org/releases/2.3/dovecot-$DOVECOT_VERSION.tar.gz |
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/local/bin/doveadm quota recalc -A' > /etc/cron.d/dovecot-sync
+RUN echo '* * * * * root /usr/local/bin/trim_logs.sh >> /dev/stdout 2>&1' > /etc/cron.d/trim_logs
+COPY trim_logs.sh /usr/local/bin/trim_logs.sh
COPY syslog-ng.conf /etc/syslog-ng/syslog-ng.conf
COPY imapsync /usr/local/bin/imapsync
COPY postlogin.sh /usr/local/bin/postlogin.sh
@@ -101,7 +108,8 @@ RUN chmod +x /usr/local/lib/dovecot/sieve/rspamd-pipe-ham \
/usr/local/lib/dovecot/sieve/rspamd-pipe-spam \
/usr/local/bin/imapsync_cron.pl \
/usr/local/bin/postlogin.sh \
- /usr/local/bin/imapsync
+ /usr/local/bin/imapsync \
+ /usr/local/bin/trim_logs.sh
RUN groupadd -g 5000 vmail \
&& groupadd -g 401 dovecot \
diff --git a/data/Dockerfiles/dovecot/docker-entrypoint.sh b/data/Dockerfiles/dovecot/docker-entrypoint.sh
index 7a6a45c9..70ffb701 100755
--- a/data/Dockerfiles/dovecot/docker-entrypoint.sh
+++ b/data/Dockerfiles/dovecot/docker-entrypoint.sh
@@ -7,10 +7,11 @@ while ! mysqladmin ping --host mysql -u${DBUSER} -p${DBPASS} --silent; do
sleep 2
done
-# Hard-code env vars to imapsync due to cron not passing them to the perl script
+# Hard-code env vars to scripts due to cron not passing them to the perl script
sed -i "/^\$DBUSER/c\\\$DBUSER='${DBUSER}';" /usr/local/bin/imapsync_cron.pl
sed -i "/^\$DBPASS/c\\\$DBPASS='${DBPASS}';" /usr/local/bin/imapsync_cron.pl
sed -i "/^\$DBNAME/c\\\$DBNAME='${DBNAME}';" /usr/local/bin/imapsync_cron.pl
+sed -i "s/LOG_LINES/${LOG_LINES}/g" /usr/local/bin/trim_logs.sh
# Create missing directories
[[ ! -d /usr/local/etc/dovecot/sql/ ]] && mkdir -p /usr/local/etc/dovecot/sql/
diff --git a/data/Dockerfiles/dovecot/syslog-ng.conf b/data/Dockerfiles/dovecot/syslog-ng.conf
index 7677d1bf..d788d3e0 100644
--- a/data/Dockerfiles/dovecot/syslog-ng.conf
+++ b/data/Dockerfiles/dovecot/syslog-ng.conf
@@ -30,14 +30,6 @@ destination d_redis_f2b_channel {
command("PUBLISH" "F2B_CHANNEL" "$MESSAGE")
);
};
-destination d_redis_cleanup {
- redis(
- host("redis-mailcow")
- persist-name("redis3")
- port(6379)
- command("LTRIM" "DOVECOT_MAILLOG" "0" "`LOG_LINES`")
- );
-};
filter f_mail { facility(mail); };
filter f_not_watchdog { not message("172\.22\.1\.248"); };
log {
@@ -47,5 +39,4 @@ log {
filter(f_mail);
destination(d_redis_ui_log);
destination(d_redis_f2b_channel);
- destination(d_redis_cleanup);
};
diff --git a/data/Dockerfiles/dovecot/trim_logs.sh b/data/Dockerfiles/dovecot/trim_logs.sh
new file mode 100755
index 00000000..f256c380
--- /dev/null
+++ b/data/Dockerfiles/dovecot/trim_logs.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+redis-cli -h redis LTRIM ACME_LOG 0 LOG_LINES
+redis-cli -h redis LTRIM POSTFIX_MAILLOG 0 LOG_LINES
+redis-cli -h redis LTRIM DOVECOT_MAILLOG 0 LOG_LINES
+redis-cli -h redis LTRIM SOGO_LOG 0 LOG_LINES
+redis-cli -h redis LTRIM NETFILTER_LOG 0 LOG_LINES