From a068a65818db2889ae30ca024caa5986321037e7 Mon Sep 17 00:00:00 2001 From: Till Skrodzki Date: Sat, 18 Jan 2025 19:02:29 +0100 Subject: [PATCH 1/5] Add DB_APPENDIX to support additional parameters With https://github.com/Mailu/Mailu/pull/3701 the remark was left to set the DB collation for MariaDB setups. However, the Helm chart has no option to overwrite the SQLAlchemy URI really. It selfs DB_USER, DB_PW, DB_NAME and DB_HOST and thus triggers the Alchemy URI to be overwritten (and it overwrites it statically as well...). This commit adds the parameter / environment variable DB_APPENDIX allowing for, e.g., '?collation=utf8mb4_unicode_ci' to be set using an environment variable which the Helm chart can then set. --- core/admin/mailu/configuration.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/admin/mailu/configuration.py b/core/admin/mailu/configuration.py index e568deb9..abc9a7e4 100644 --- a/core/admin/mailu/configuration.py +++ b/core/admin/mailu/configuration.py @@ -25,6 +25,7 @@ DEFAULT_CONFIG = { 'DB_PW': None, 'DB_HOST': 'database', 'DB_NAME': 'mailu', + 'DB_APPENDIX': '', 'SQLITE_DATABASE_FILE': 'data/main.db', 'SQLALCHEMY_DATABASE_URI': 'sqlite:////data/main.db', 'SQLALCHEMY_DATABASE_URI_ROUNDCUBE': 'sqlite:////data/roundcube.db', @@ -102,8 +103,8 @@ class ConfigManager: DB_TEMPLATES = { 'sqlite': 'sqlite:////{SQLITE_DATABASE_FILE}', - 'postgresql': 'postgresql://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}', - 'mysql': 'mysql+mysqlconnector://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}', + 'postgresql': 'postgresql://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}{DB_APPENDIX}', + 'mysql': 'mysql+mysqlconnector://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}{DB_APPENDIX}', } def __init__(self): From da10c88a2f2142d08eb6037228c3973ef4ac3196 Mon Sep 17 00:00:00 2001 From: Till Skrodzki Date: Sat, 18 Jan 2025 19:03:31 +0100 Subject: [PATCH 2/5] Add uvloop for prod execution postfix-mta-sts-resolver can optionally use uvloop speeding up asyncio execution --- core/base/requirements-prod.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/core/base/requirements-prod.txt b/core/base/requirements-prod.txt index 40b97bc4..81f32289 100644 --- a/core/base/requirements-prod.txt +++ b/core/base/requirements-prod.txt @@ -78,6 +78,7 @@ tabulate==0.9.0 tenacity==8.2.3 typing_extensions==4.11.0 urllib3==2.2.1 +uvloop==0.21.0 validators==0.28.1 visitor==0.1.3 vobject==0.9.7 From a5cdf27534fdfefc11cbcf5a5b7da5e6825c2b3c Mon Sep 17 00:00:00 2001 From: Till Skrodzki Date: Sat, 18 Jan 2025 21:24:49 +0100 Subject: [PATCH 3/5] Update docs for DB_APPENDIX --- docs/faq.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/faq.rst b/docs/faq.rst index 5b4c153f..5caa5be9 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -992,6 +992,7 @@ Admin container fails to connect to external MariaDB database ````````````````````````````````````````````````````````````` If the admin container is `unable to connect to an external MariaDB database due to incompatible collation`_, you may need to change the ``SQLALCHEMY_DATABASE_URI`` setting to ensure the right connector is used. +Alternatively, you may set ``DB_APPENDIX`` accordingly. For example: ``?collation=utf8mb4_unicode_ci`` is appended as is just after the database name in case DB_TYPE and related values are set. MariaDB has no support for utf8mb4_0900_ai_ci which is the new default since MySQL version 8.0. From 0ff1d4858eccad05c50176a0d97d6c1589043cfb Mon Sep 17 00:00:00 2001 From: Till Skrodzki Date: Sun, 16 Feb 2025 23:13:12 +0100 Subject: [PATCH 4/5] Add uvloop to requirements-dev.txt --- core/base/requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/base/requirements-dev.txt b/core/base/requirements-dev.txt index 3d2495fb..9b27a124 100644 --- a/core/base/requirements-dev.txt +++ b/core/base/requirements-dev.txt @@ -46,6 +46,7 @@ watchdog # core/postfix postfix-mta-sts-resolver +uvloop # core/oletools python-magic @@ -56,4 +57,3 @@ requests # optional/radicale radicale - From ebd3459738ff280ed9813b61fa2eca6caf850628 Mon Sep 17 00:00:00 2001 From: Till Skrodzki Date: Mon, 24 Feb 2025 21:05:38 +0100 Subject: [PATCH 5/5] Add towncrier entry for PR #3729 --- towncrier/newsfragments/3729.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 towncrier/newsfragments/3729.misc diff --git a/towncrier/newsfragments/3729.misc b/towncrier/newsfragments/3729.misc new file mode 100644 index 00000000..492d4998 --- /dev/null +++ b/towncrier/newsfragments/3729.misc @@ -0,0 +1 @@ +Add optional DB_APPENDIX configuration parameter which is appended as is to the postgresql or mysql URI \ No newline at end of file