From e499d5a8049772aaf011f1ed41a0c475edfed7dd Mon Sep 17 00:00:00 2001 From: Dario Ernst Date: Sat, 4 Jan 2020 18:04:25 +0100 Subject: [PATCH] Add xapian full-text-search plugin to dovecot Currently we are not able to offer our users a FTS experience after the demise of lucene due to unfixed coredumps with musl/alpine. We now add lucene, the only remaining maintained small/lean FTS plugin for dovecot. It is quite simple to add to our stack: A two-stage docker build is used to compile the fts plugin in the first stage, and copy over only the resulting plugin-artifact to the second stage, which is our usual dovecot container. Configuration is also minimal. --- core/dovecot/Dockerfile | 15 ++++++++++++++- core/dovecot/conf/dovecot.conf | 9 ++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/core/dovecot/Dockerfile b/core/dovecot/Dockerfile index bb67370c..5a715099 100644 --- a/core/dovecot/Dockerfile +++ b/core/dovecot/Dockerfile @@ -1,4 +1,15 @@ ARG DISTRO=alpine:3.10 +FROM $DISTRO +WORKDIR /tmp +RUN apk add git build-base automake autoconf libtool dovecot-dev xapian-core-dev icu-dev +RUN git clone https://github.com/grosjo/fts-xapian.git \ + && cd fts-xapian \ + # && git checkout 1.2.7 \ # TODO: when upstream releases 1.2.7, use that + && autoreconf -vi \ + && PANDOC=false ./configure --with-dovecot=/usr/lib/dovecot \ + && make \ + && make install + FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ @@ -13,9 +24,11 @@ RUN pip3 install "podop>0.2.5" # Image specific layers under this line RUN apk add --no-cache \ - dovecot dovecot-lmtpd dovecot-pop3d dovecot-submissiond dovecot-pigeonhole-plugin rspamd-client \ + dovecot dovecot-lmtpd dovecot-pop3d dovecot-submissiond dovecot-pigeonhole-plugin rspamd-client xapian-core \ && mkdir /var/lib/dovecot +COPY --from=0 /usr/lib/dovecot/lib21_fts_xapian_plugin.* /usr/lib/dovecot/ + COPY conf /conf COPY start.py /start.py diff --git a/core/dovecot/conf/dovecot.conf b/core/dovecot/conf/dovecot.conf index f4181e0c..aa33a7bb 100644 --- a/core/dovecot/conf/dovecot.conf +++ b/core/dovecot/conf/dovecot.conf @@ -21,7 +21,8 @@ mail_access_groups = mail maildir_stat_dirs = yes mailbox_list_index = yes mail_vsize_bg_after_count = 100 -mail_plugins = $mail_plugins quota quota_clone zlib +mail_plugins = $mail_plugins quota quota_clone zlib fts fts_xapian +default_vsz_limit = 2GB namespace inbox { inbox = yes @@ -38,6 +39,12 @@ plugin { quota_vsizes = yes quota_clone_dict = proxy:/tmp/podop.socket:quota + fts = xapian + fts_xapian = partial=2 full=30 + fts_autoindex = yes + fts_enforced = yes + fts_autoindex_exclude = \Trash + {% if COMPRESSION in [ 'gz', 'bz2' ] %} zlib_save = {{ COMPRESSION }} {% endif %}