diff --git a/setup/flavors/compose/docker-compose.yml b/setup/flavors/compose/docker-compose.yml index cc45ca99..12490189 100644 --- a/setup/flavors/compose/docker-compose.yml +++ b/setup/flavors/compose/docker-compose.yml @@ -13,6 +13,16 @@ services: restart: always volumes: - "{{ root }}/redis:/data" + + {% if db_flavor == 'postgresql' and postgresql == 'internal' %} + database: + image: ${DOCKER_ORG:-mailu}/postgresql:${MAILU_VERSION:-{{ version }}} + restart: always + env_file: {{ env }} + volumes: + - "{{ root }}/data/psql_db:/data" + - "{{ root }}/data/psql_backup:/backup" + {% endif %} # Core services front: diff --git a/setup/flavors/compose/mailu.env b/setup/flavors/compose/mailu.env index 3f67b0dd..b0da2127 100644 --- a/setup/flavors/compose/mailu.env +++ b/setup/flavors/compose/mailu.env @@ -158,3 +158,15 @@ REAL_IP_FROM={{ real_ip_from }} # choose wether mailu bounces (no) or rejects (yes) mail when recipient is unknown (value: yes, no) REJECT_UNLISTED_RECIPIENT={{ reject_unlisted_recipient }} + +################################### +# Advanced settings +################################### +DB_FLAVOR = {{ db_flavor }} +{% if postgresql == 'external' %} +DB_USER={{ db_user }} +DB_PW={{ db_pw }} +DB_URL={{ db_url }} +DB_NAME={{ db_name }} +{% endif %} + diff --git a/setup/static/render.js b/setup/static/render.js index a1c3fb0d..2a265139 100644 --- a/setup/static/render.js +++ b/setup/static/render.js @@ -31,4 +31,46 @@ $(document).ready(function() { $("#admin_path").attr("value", ""); } }); -}); \ No newline at end of file +}); + +$(document).ready(function() { + if ($("#database").val() == 'sqlite') { + $("#postgres_db").hide(); + } else { + $("#postgres_db").show(); + } + if ($('#external_psql').prop('checked')) { + $("#external_db").show(); + } + $("#database").click(function() { + if (this.value == 'sqlite') { + $("#postgres_db").hide(); + } else { + $("#postgres_db").show(); + } + }); + $("#external_psql").change(function() { + if ($(this).is(":checked")) { + $("#external_db").show(); + $("#db_user").prop('required',true); + $("#db_pw").prop('required',true); + $("#db_url").prop('required',true); + $("#db_name").prop('required',true); + } else { + $("#external_db").hide(); + } + }); + $("#internal_psql").change(function() { + if ($(this).is(":checked")) { + $("#external_db").hide(); + $("#db_user").val(""); + $("#db_pw").val(""); + $("#db_url").val(""); + $("#db_name").val(""); + $("#db_user").prop('required',false); + $("#db_pw").prop('required',false); + $("#db_url").prop('required',false); + $("#db_name").prop('required',false); + } + }); +}); diff --git a/setup/templates/steps/database.html b/setup/templates/steps/database.html new file mode 100644 index 00000000..811be2e0 --- /dev/null +++ b/setup/templates/steps/database.html @@ -0,0 +1,39 @@ +{% call macros.panel("info", "Database preferences") %} + +
+ +
+ +

+ +
+ +{% endcall %} \ No newline at end of file diff --git a/setup/templates/wizard.html b/setup/templates/wizard.html index 05de5a5c..e618b716 100644 --- a/setup/templates/wizard.html +++ b/setup/templates/wizard.html @@ -19,6 +19,7 @@ {%for file in steps %} {% include "steps/" + flavor + "/" + file %} {% endfor %} + {% include "steps/database.html" %} {% endif %}