Skip to content

Commit 3e8bb06

Browse files
authored
dovecot: replace solr fts with flatcurve (xapian) (#5680)
* fts-flatcurve: inital implementation * fts: removed solr from compose.yml * flatcurve: added heap and proc logic to dovecot * added logic for update.sh & generate for Flatcurve * delete old iteration of fts-flatcurve.conf * updated default fts.conf * updated .gitignore to exclude fts.conf for further git updates * Remove autogeneration of fts.conf (disable override) * cleanup all left solr stuff * renamed SKIP_FLATCURVE to SKIP_FTS * cleanup leftovers solr in lang files * moved lazy_expunge plugin only to mail_plugins * added fts timeout value * compose: remove dev image of dovecot * updated japanese translation
1 parent b087ac9 commit 3e8bb06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+467
-862
lines changed

.github/workflows/image_builds.yml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
- "postfix-mailcow"
2424
- "rspamd-mailcow"
2525
- "sogo-mailcow"
26-
- "solr-mailcow"
2726
- "unbound-mailcow"
2827
- "watchdog-mailcow"
2928
runs-on: ubuntu-latest

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ data/conf/dovecot/sni.conf
2323
data/conf/dovecot/sogo-sso.conf
2424
data/conf/dovecot/sogo_trusted_ip.conf
2525
data/conf/dovecot/sql
26+
data/conf/dovecot/conf.d/fts.conf
2627
data/conf/nextcloud-*.bak
2728
data/conf/nginx/*.active
2829
data/conf/nginx/*.bak

data/Dockerfiles/dovecot/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ RUN addgroup -g 5000 vmail \
105105
dovecot-submissiond \
106106
dovecot-pigeonhole-plugin \
107107
dovecot-pop3d \
108-
dovecot-fts-solr \
109108
dovecot-fts-flatcurve \
110109
&& arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) \
111110
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$arch" \

data/Dockerfiles/dovecot/docker-entrypoint.sh

+15-56
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,16 @@ EOF
110110

111111
echo -n ${ACL_ANYONE} > /etc/dovecot/acl_anyone
112112

113-
if [[ "${FLATCURVE_EXPERIMENTAL}" =~ ^([yY][eE][sS]|[yY]) ]]; then
114-
echo -e "\e[33mActivating Flatcurve as FTS Backend...\e[0m"
115-
echo -e "\e[33mDepending on your previous setup a full reindex might be needed... \e[0m"
116-
echo -e "\e[34mVisit https://docs.mailcow.email/manual-guides/Dovecot/u_e-dovecot-fts/#fts-related-dovecot-commands to learn how to reindex\e[0m"
117-
echo -n 'quota acl zlib mail_crypt mail_crypt_acl mail_log notify fts fts_flatcurve listescape replication lazy_expunge' > /etc/dovecot/mail_plugins
118-
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve mail_crypt mail_crypt_acl notify mail_log fts fts_flatcurve listescape replication' > /etc/dovecot/mail_plugins_imap
119-
echo -n 'quota sieve acl zlib mail_crypt mail_crypt_acl fts fts_flatcurve notify listescape replication' > /etc/dovecot/mail_plugins_lmtp
120-
elif [[ "${SKIP_SOLR}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
113+
if [[ "${SKIP_FTS}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
114+
echo -e "\e[33mDetecting SKIP_FTS=y... not enabling Flatcurve (FTS) then...\e[0m"
121115
echo -n 'quota acl zlib mail_crypt mail_crypt_acl mail_log notify listescape replication lazy_expunge' > /etc/dovecot/mail_plugins
122116
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve mail_crypt mail_crypt_acl notify listescape replication mail_log' > /etc/dovecot/mail_plugins_imap
123117
echo -n 'quota sieve acl zlib mail_crypt mail_crypt_acl notify listescape replication' > /etc/dovecot/mail_plugins_lmtp
124118
else
125-
echo -n 'quota acl zlib mail_crypt mail_crypt_acl mail_log notify fts fts_solr listescape replication lazy_expunge' > /etc/dovecot/mail_plugins
126-
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve mail_crypt mail_crypt_acl notify mail_log fts fts_solr listescape replication' > /etc/dovecot/mail_plugins_imap
127-
echo -n 'quota sieve acl zlib mail_crypt mail_crypt_acl fts fts_solr notify listescape replication' > /etc/dovecot/mail_plugins_lmtp
119+
echo -e "\e[32mDetecting SKIP_FTS=n... enabling Flatcurve (FTS)\e[0m"
120+
echo -n 'quota acl zlib mail_crypt mail_crypt_acl mail_log notify fts fts_flatcurve listescape replication lazy_expunge' > /etc/dovecot/mail_plugins
121+
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve mail_crypt mail_crypt_acl notify mail_log fts fts_flatcurve listescape replication' > /etc/dovecot/mail_plugins_imap
122+
echo -n 'quota sieve acl zlib mail_crypt mail_crypt_acl fts fts_flatcurve notify listescape replication' > /etc/dovecot/mail_plugins_lmtp
128123
fi
129124
chmod 644 /etc/dovecot/mail_plugins /etc/dovecot/mail_plugins_imap /etc/dovecot/mail_plugins_lmtp /templates/quarantine.tpl
130125

@@ -247,51 +242,6 @@ function script_deinit()
247242
end
248243
EOF
249244

250-
# Temporarily set FTS depending on user choice inside mailcow.conf. Will be removed as soon as Solr is dropped
251-
if [[ "${FLATCURVE_EXPERIMENTAL}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
252-
cat <<EOF > /etc/dovecot/conf.d/fts.conf
253-
# Autogenerated by mailcow
254-
plugin {
255-
fts_autoindex = yes
256-
fts_autoindex_exclude = \Junk
257-
fts_autoindex_exclude2 = \Trash
258-
fts = flatcurve
259-
260-
# Maximum term length can be set via the 'maxlen' argument (maxlen is
261-
# specified in bytes, not number of UTF-8 characters)
262-
fts_tokenizer_email_address = maxlen=100
263-
fts_tokenizer_generic = algorithm=simple maxlen=30
264-
265-
# These are not flatcurve settings, but required for Dovecot FTS. See
266-
# Dovecot FTS Configuration link above for further information.
267-
fts_languages = en es de
268-
fts_tokenizers = generic email-address
269-
270-
# OPTIONAL: Recommended default FTS core configuration
271-
fts_filters = normalizer-icu snowball stopwords
272-
fts_filters_en = lowercase snowball english-possessive stopwords
273-
}
274-
EOF
275-
elif [[ ! "${SKIP_SOLR}" =~ ^([yY][eE][sS]|[yY])$ ]]; then
276-
cat <<EOF > /etc/dovecot/conf.d/fts.conf
277-
# Autogenerated by mailcow
278-
plugin {
279-
fts = solr
280-
fts_autoindex = yes
281-
fts_autoindex_exclude = \Junk
282-
fts_autoindex_exclude2 = \Trash
283-
fts_solr = url=http://solr:8983/solr/dovecot-fts/
284-
285-
fts_tokenizers = generic email-address
286-
fts_tokenizer_generic = algorithm=simple
287-
288-
fts_filters = normalizer-icu snowball stopwords
289-
fts_filters_en = lowercase snowball english-possessive stopwords
290-
}
291-
EOF
292-
fi
293-
294-
295245
# Replace patterns in app-passdb.lua
296246
sed -i "s/__DBUSER__/${DBUSER}/g" /etc/dovecot/lua/passwd-verify.lua
297247
sed -i "s/__DBPASS__/${DBPASS}/g" /etc/dovecot/lua/passwd-verify.lua
@@ -398,6 +348,15 @@ mail_replica = tcp:${MAILCOW_REPLICA_IP}:${DOVEADM_REPLICA_PORT}
398348
EOF
399349
fi
400350

351+
# Setting variables for indexer-worker inside fts.conf automatically according to mailcow.conf settings
352+
if [[ "${SKIP_FTS}" =~ ^([nN][oO]|[nN])+$ ]]; then
353+
echo -e "\e[94mConfiguring FTS Settings...\e[0m"
354+
echo -e "\e[94mSetting FTS Memory Limit (per process) to ${FTS_HEAP} MB\e[0m"
355+
sed -i "s/vsz_limit\s*=\s*[0-9]*\s*MB*/vsz_limit=${FTS_HEAP} MB/" /etc/dovecot/conf.d/fts.conf
356+
echo -e "\e[94mSetting FTS Process Limit to ${FTS_PROCS}\e[0m"
357+
sed -i "s/process_limit\s*=\s*[0-9]*/process_limit=${FTS_PROCS}/" /etc/dovecot/conf.d/fts.conf
358+
fi
359+
401360
# 401 is user dovecot
402361
if [[ ! -s /mail_crypt/ecprivkey.pem || ! -s /mail_crypt/ecpubkey.pem ]]; then
403362
openssl ecparam -name prime256v1 -genkey | openssl pkey -out /mail_crypt/ecprivkey.pem
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
if [[ "${SKIP_SOLR}" =~ ^([yY][eE][sS]|[yY])+$ && ! "${FLATCURVE_EXPERIMENTAL}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
3+
if [[ "${SKIP_FTS}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
44
exit 0
55
else
66
doveadm fts optimize -A
7-
fi
7+
fi

data/Dockerfiles/solr/Dockerfile

-31
This file was deleted.

0 commit comments

Comments
 (0)