Merge remote-tracking branch 'upstream/master' into extend-nginx

This commit is contained in:
Tim Möhlmann
2018-12-07 16:48:50 +02:00
85 changed files with 2283 additions and 645 deletions

View File

@@ -12,6 +12,7 @@ COPY setup.py ./setup.py
COPY main.py ./main.py
COPY flavors /data/master/flavors
COPY templates /data/master/templates
COPY static ./static
#RUN python setup.py https://github.com/mailu/mailu /data

59
setup/README.md Normal file
View File

@@ -0,0 +1,59 @@
## Adding more flavors/steps
(Everything will go under setup/ directory - using Kubernetes flavor as example)
Until this point, the app is working as it follows:
- when accesing the setup page it will display the flavors selection step (`templates/steps/flavor.html`)
- after you choose your desired flavor it will iterare over the files in the flavor directory and building the page
(`templates/steps/config.html is general for all flavors`)
- when you complete all required fields and press "Setup Mailu" button it will redirect you to the setup page (`flavors/choosen-flavor/setup.html`)
To add a new flavor you need to create a directory under `templates/steps/` in which you are adding actual steps.
Eg: Adding a WIP step we'll create `templates/steps/kubernetes/wip.html`
*Note that wizard.html is iterating over files in this directory and building the page. Files are prefixed with a number for sorting purposes.*
wip.html will start with
```
{% call macros.panel("info", "Step X - Work in progress") %}
```
and end with
```
{% endcall %}
```
You store variable from front-page using the name attribute inside tag.
In the example below the string entered in the input field is stored in the variable `named var_test`
```
<input type="text" name="var_test">
```
In order to user the variable furter you use it like `{{ var_test }}`
In the setup page (`flavors/kubernetes/setup.html`) you cand add steps by importing macros
```
{% import "macros.html" as macros %}
```
and start and end every step with
```
{% call macros.panel("info", "Step X - Title") %}
-------------------
{% endcall %}
```
### Generating a file
Create the file template in `flavors/kubernetes/` (eg. file.txt) in which you save your variables
```
ROOT = {{ root }}
MY_VAR = {{ var_test }}
```
When you submit to Setup Mailu the file will be generated. In order to get the file add the following command to setup.html
```
<p>curl {{ url_for('.file', uid=uid, filepath='file.txt', _external=True) }} > file.txt</p>
```

View File

@@ -1,13 +1,13 @@
# This file is used to run the mailu/setup utility
version: '2'
version: '3.6'
services:
redis:
image: redis:alpine
setup:
image: mailu/setup
image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX}setup:${MAILU_VERSION:-master}
ports:
- "8000:80"
build: .

View File

@@ -10,13 +10,17 @@ services:
# External dependencies
redis:
image: redis:alpine
restart: always
volumes:
- "{{ root }}/redis:/data"
# Core services
front:
image: mailu/nginx:{{ version }}
image: ${DOCKER_ORG:-mailu}/nginx:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
logging:
driver: {{ log_driver or 'json-file' }}
ports:
{% for port in (80, 443, 25, 465, 587, 110, 995, 143, 993) %}
{% if bind4 %}
@@ -41,7 +45,8 @@ services:
{% endif %}
admin:
image: mailu/admin:{{ version }}
image: ${DOCKER_ORG:-mailu}/admin:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
{% if not admin_enabled %}
ports:
@@ -54,7 +59,8 @@ services:
- redis
imap:
image: mailu/dovecot:{{ version }}
image: ${DOCKER_ORG:-mailu}/dovecot:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
volumes:
- "{{ root }}/mail:/mail"
@@ -63,7 +69,8 @@ services:
- front
smtp:
image: mailu/postfix:{{ version }}
image: ${DOCKER_ORG:-mailu}/postfix:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
volumes:
- "{{ root }}/overrides:/overrides"
@@ -75,10 +82,9 @@ services:
- {{ dns }}
{% endif %}
# Optional services
{% if antispam_enabled %}
antispam:
image: mailu/rspamd:{{ version }}
image: ${DOCKER_ORG:-mailu}/rspamd:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
volumes:
- "{{ root }}/filter:/var/lib/rspamd"
@@ -91,11 +97,12 @@ services:
dns:
- {{ dns }}
{% endif %}
{% endif %}
# Optional services
{% if antivirus_enabled %}
antivirus:
image: mailu/clamav:{{ version }}
image: ${DOCKER_ORG:-mailu}/clamav:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
volumes:
- "{{ root }}/filter:/data"
@@ -109,7 +116,8 @@ services:
{% if webdav_enabled %}
webdav:
image: mailu/radicale:{{ version }}
image: ${DOCKER_ORG:-mailu}/radicale:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
volumes:
- "{{ root }}/dav:/data"
@@ -117,7 +125,8 @@ services:
{% if fetchmail_enabled %}
fetchmail:
image: mailu/fetchmail:{{ version }}
image: ${DOCKER_ORG:-mailu}/fetchmail:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
{% if resolver_enabled %}
depends_on:
@@ -130,7 +139,8 @@ services:
# Webmail
{% if webmail_type != 'none' %}
webmail:
image: mailu/{{ webmail_type }}:{{ version }}
image: ${DOCKER_ORG:-mailu}/{{ webmail_type }}:${MAILU_VERSION:-{{ version }}}
restart: always
env_file: {{ env }}
volumes:
- "{{ root }}/webmail:/data"

View File

@@ -73,6 +73,7 @@ ANTISPAM={{ antispam_enabled or 'none'}}
# Message size limit in bytes
# Default: accept messages up to 50MB
# Max attachment size will be 33% smaller
MESSAGE_SIZE_LIMIT={{ message_size_limit or '50000000' }}
# Networks granted relay permissions, make sure that you include your Docker
@@ -144,7 +145,7 @@ DOMAIN_REGISTRATION=true
# json-file (default)
# journald (On systemd platforms, useful for Fail2Ban integration)
# syslog (Non systemd platforms, Fail2Ban integration. Disables `docker-compose log` for front!)
LOG_DRIVER={{ log_driver or 'json-file' }}
# LOG_DRIVER={{ log_driver or 'json-file' }}
# Docker-compose project name, this will prepended to containers names.
COMPOSE_PROJECT_NAME={{ compose_project_name or 'mailu' }}

View File

@@ -28,15 +28,15 @@ files before going any further.</p>
{% call macros.panel("info", "Step 3 - Start the Compose project") %}
<p>To start your compose project, simply run the Docker Compose <code>up</code>
command.</p>
command using <code>-p mailu</code> flag for project name.</p>
<pre><code>cd {{ root }}
docker-compose up -d
docker-compose -p mailu up -d
</pre></code>
Before you can use Mailu, you must create the primary administrator user account. This should be {{ postmaster }}@{{ domain }}. Use the following command, changing PASSWORD to your liking:
<pre><code>docker-compose exec admin python manage.py admin {{ postmaster }} {{ domain }} PASSWORD
<pre><code>docker-compose -p mailu exec admin python manage.py admin {{ postmaster }} {{ domain }} PASSWORD
</pre></code>
<p>Login to the admin interface to change the password for a safe one, at

View File

@@ -10,14 +10,15 @@ services:
# External dependencies
redis:
image: redis:alpine
restart: always
volumes:
- "{{ root }}/redis:/data"
# Core services
front:
image: mailu/nginx:{{ version }}
image: ${DOCKER_ORG:-mailu}/nginx:${MAILU_VERSION:-{{ version }}}
env_file: {{ env }}
logging:
driver: {{ log_driver or 'json-file' }}
ports:
{% for port in (80, 443, 25, 465, 587, 110, 995, 143, 993) %}
- target: {{ port }}
@@ -28,7 +29,7 @@ services:
- "{{ root }}/certs:/certs"
- "{{ root }}/overrides/nginx:/overrides"
deploy:
replicas: 1
replicas: {{ front_replicas }}
{% if resolver_enabled %}
resolver:
@@ -40,7 +41,7 @@ services:
{% endif %}
admin:
image: mailu/admin:{{ version }}
image: ${DOCKER_ORG:-mailu}/admin:${MAILU_VERSION:-{{ version }}}
env_file: {{ env }}
{% if not admin_enabled %}
ports:
@@ -50,10 +51,10 @@ services:
- "{{ root }}/data:/data"
- "{{ root }}/dkim:/dkim"
deploy:
replicas: 1
replicas: {{ admin_replicas }}
imap:
image: mailu/dovecot:{{ version }}
image: ${DOCKER_ORG:-mailu}/dovecot:${MAILU_VERSION:-{{ version }}}
env_file: {{ env }}
environment:
# Default to 10.0.1.0/24
@@ -62,26 +63,24 @@ services:
- "{{ root }}/mail:/mail"
- "{{ root }}/overrides:/overrides"
deploy:
replicas: 1
replicas: {{ imap_replicas }}
smtp:
image: mailu/postfix:{{ version }}
image: ${DOCKER_ORG:-mailu}/postfix:${MAILU_VERSION:-{{ version }}}
env_file: {{ env }}
environment:
- POD_ADDRESS_RANGE={{ subnet }}
volumes:
- "{{ root }}/overrides:/overrides"
deploy:
replicas: 1
replicas: {{ smtp_replicas }}
{% if resolver_enabled %}
dns:
- {{ dns }}
{% endif %}
# Optional services
{% if antispam_enabled %}
antispam:
image: mailu/rspamd:{{ version }}
image: ${DOCKER_ORG:-mailu}/rspamd:${MAILU_VERSION:-{{ version }}}
env_file: {{ env }}
environment:
- POD_ADDRESS_RANGE={{ subnet }}
@@ -95,11 +94,11 @@ services:
dns:
- {{ dns }}
{% endif %}
{% endif %}
# Optional services
{% if antivirus_enabled %}
antivirus:
image: mailu/clamav:{{ version }}
image: ${DOCKER_ORG:-mailu}/clamav:${MAILU_VERSION:-{{ version }}}
env_file: {{ env }}
volumes:
- "{{ root }}/filter:/data"
@@ -113,7 +112,7 @@ services:
{% if webdav_enabled %}
webdav:
image: mailu/none:{{ version }}
image: ${DOCKER_ORG:-mailu}/none:${MAILU_VERSION:-{{ version }}}
env_file: {{ env }}
volumes:
- "{{ root }}/dav:/data"
@@ -123,7 +122,7 @@ services:
{% if fetchmail_enabled %}
fetchmail:
image: mailu/fetchmail:{{ version }}
image: ${DOCKER_ORG:-mailu}/fetchmail:${MAILU_VERSION:-{{ version }}}
env_file: {{ env }}
volumes:
- "{{ root }}/data:/data"
@@ -137,7 +136,7 @@ services:
{% if webmail_type != 'none' %}
webmail:
image: mailu/roundcube:{{ version }}
image: ${DOCKER_ORG:-mailu}/roundcube:${MAILU_VERSION:-{{ version }}}
env_file: {{ env }}
volumes:
- "{{ root }}/webmail:/data"

34
setup/static/render.js Normal file
View File

@@ -0,0 +1,34 @@
$(document).ready(function() {
if ($("#webmail").val() == 'none') {
$("#webmail_path").hide();
$("#webmail_path").attr("value", "");
} else {
$("#webmail_path").show();
$("#webmail_path").attr("value", "/webmail");
}
$("#webmail").click(function() {
if (this.value == 'none') {
$("#webmail_path").hide();
$("#webmail_path").attr("value", "");
} else {
$("#webmail_path").show();
$("#webmail_path").attr("value", "/webmail");
}
});
});
$(document).ready(function() {
if ($('#admin').prop('checked')) {
$("#admin_path").show();
$("#admin_path").attr("value", "/admin");
}
$("#admin").change(function() {
if ($(this).is(":checked")) {
$("#admin_path").show();
$("#admin_path").attr("value", "/admin");
} else {
$("#admin_path").hide();
$("#admin_path").attr("value", "");
}
});
});

View File

@@ -15,15 +15,14 @@ accessing messages for beginner users.</p>
<!-- {{ macros.radio("webmail_type", "rainloop", "Rainloop", "lightweight Webmail based on PHP, no database") }} -->
<!-- </div> -->
<br/>
<select class="btn btn-primary dropdown-toggle" name="webmail_type">
<select class="btn btn-primary dropdown-toggle" name="webmail_type" id="webmail">
{% for webmailtype in ["none", "roundcube", "rainloop"] %}
<option value="{{ webmailtype }}" >{{ webmailtype }}</option>
{% endfor %}
</select>
<p></p>
<div class="input-group">
<!-- <div class="input-group-addon"><input type="checkbox" name="webmail_enabled" value="true"></div> -->
<input class="form-control" type="text" name="webmail_path" value="/webmail">
<input class="form-control" type="text" name="webmail_path" id="webmail_path" style="display: none">
</div>
</div>
@@ -32,12 +31,6 @@ will prevent Mailu from doing spam filtering, virus filtering, and from applying
white and blacklists that you may configure in the admin interface. You may
also disable the antivirus if required (it does use aroung 1GB of ram).</p>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="antispam_enabled" value="rspamd" checked>
Enable the spam filtering service
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="antivirus_enabled" value="clamav">
@@ -59,4 +52,9 @@ also disable the antivirus if required (it does use aroung 1GB of ram).</p>
</label>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="{{ url_for('static', filename='render.js') }}"></script>
{% endcall %}

View File

@@ -68,11 +68,13 @@ Or in plain english: if receivers start to classify your mail as spam, this post
manage your email domains, users, etc.</p>
<div class="form-group">
<label>Enable the admin UI (and path to the admin UI)</label>
<div class="input-group">
<div class="input-group-addon"><input type="checkbox" name="admin_enabled" value="true"></div>
<input class="form-control" type="text" name="admin_path" value="/admin">
</div>
<input type="checkbox" name="admin_enabled" value="true" id="admin">
<label>Enable the admin UI (and path to the admin UI)</label>
<input class="form-control" type="text" name="admin_path" id="admin_path" style="display: none">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="{{ url_for('static', filename='render.js') }}"></script>
{% endcall %}

View File

@@ -15,15 +15,14 @@ accessing messages for beginner users.</p>
<!-- {{ macros.radio("webmail_type", "rainloop", "Rainloop", "lightweight Webmail based on PHP, no database") }} -->
<!-- </div> -->
<br/>
<select class="btn btn-primary dropdown-toggle" name="webmail_type">
<select class="btn btn-primary dropdown-toggle" name="webmail_type" id="webmail">
{% for webmailtype in ["none", "roundcube", "rainloop"] %}
<option value="{{ webmailtype }}" >{{ webmailtype }}</option>
{% endfor %}
</select>
<p></p>
<div class="input-group">
<!-- <div class="input-group-addon"><input type="checkbox" name="webmail_enabled" value="true"></div> -->
<input class="form-control" type="text" name="webmail_path" value="/webmail">
<input class="form-control" type="text" name="webmail_path" id="webmail_path" style="display: none">
</div>
</div>
@@ -32,12 +31,6 @@ will prevent Mailu from doing spam filtering, virus filtering, and from applying
white and blacklists that you may configure in the admin interface. You may
also disable the antivirus if required (it does use aroung 1GB of ram).</p>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="antispam_enabled" value="rspamd" checked>
Enable the spam filtering service
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="antivirus_enabled" value="clamav">
@@ -59,4 +52,8 @@ also disable the antivirus if required (it does use aroung 1GB of ram).</p>
</label>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="{{ url_for('static', filename='render.js') }}"></script>
{% endcall %}

View File

@@ -0,0 +1,28 @@
{% call macros.panel("info", "Step 5 - Number of replicas for containers") %}
<p>Select number of replicas for containers</p>
<div class="form-group">
<input class="form-control" type="number" name="front_replicas" min="1" required value="1"
style="width: 6%; display: inline;">
<label>Front</label>
</div>
<div class="form-group">
<input class="form-control" type="number" name="admin_replicas" min="1" required value="1"
style="width: 6%; display: inline;">
<label>Admin</label>
</div>
<div class="form-group">
<input class="form-control" type="number" name="imap_replicas" min="1" required value="1"
style="width: 6%; display: inline;">
<label>IMAP</label>
</div>
<div class="form-group">
<input class="form-control" type="number" name=smtp_replicas min="1" required value="1"
style="width: 6%; display: inline;">
<label>SMPT</label>
</div>
{% endcall %}