Skip to content
Snippets Groups Projects
Commit d3bb45e8 authored by Alexander Drummer's avatar Alexander Drummer
Browse files

added DKIM_SELECTOR environment variable

parent 311b524e
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ ENV LIST_LANGUAGE_CODE en
ENV LIST_LANGUAGE_NAME English
ENV LIST_ADMIN admin@lists.example.com
ENV DEBUG_CONTAINER false
ENV DKIM_SELECTOR mailinglist
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
......@@ -41,6 +42,8 @@ VOLUME /var/log/
VOLUME /var/log/apache2
VOLUME /var/lib/mailman/archives
VOLUME /var/lib/mailman/lists
VOLUME /etc/dkimkeys
EXPOSE 25 80
......
......@@ -35,7 +35,7 @@ The following components are included:
You can download the image using the following command:
```bash
docker pull drummerroma/mailman2:20.04-Postfix
docker pull drummerroma/mailman2:20.04-postfix
```
Host name
......@@ -95,6 +95,14 @@ This image uses several environment variables to define different values to be u
* Accepted values: `false`, `true`
* Description: Used to control the output of the container. By default, only relevant information will be displayed. If you want to output every command executed during setup, run the container with `-e DEBUG_CONTAINER=true`.
----
* Variable name: `DKIM_SELECTOR`
* Default value: `mailinglist`
* Accepted values: Any string
* Description: Used as Selector for DKIM Record.
Exposed port and volumes
----
......@@ -106,7 +114,7 @@ Also exports six volumes:
- `/var/log/apache2`: Logs for Apache webserver.
- `/var/lib/mailman/archives`: Mailman mailing lists archives.
- `/var/lib/mailman/lists`: Mailman mailing lists.
- `/etc/exim4/tls.d`: Exim DKIM keys. Expected to contain `private.key` and `public.key` files. If omitted, a new pair of keys will be created on runtime.
- `/etc/dkimkeys`: Opendkim DKIM keys. Expected to contain `private.key` and `public.key` files. If omitted, a new pair of keys will be created on runtime.
Recommendations
----
......@@ -125,22 +133,74 @@ Use cases
1. Run a temporary container for testing purposes with default values:
```
docker run -i -t --rm -h lists.example.com -e DEBUG_CONTAINER=true drummerroma/mailman2:20.04-Postfix
docker run -i -t --rm -h lists.example.com -e DEBUG_CONTAINER=true drummerroma/mailman2:20.04-postfix
```
2. Run a production container for domain `whatever.example.com` without exported volumes:
```
docker run -d --restart=always -h whatever.example.com -e URL_FQDN=whatever.example.com -e EMAIL_FQDN=whatever.example.com -e MASTER_PASSWORD=SecretPassword -e LIST_ADMIN=whoever@example.com -p 49780:80 -p 25:25 drummerroma/mailman2:20.04-Postfix
docker run -d --restart=always -h whatever.example.com -e URL_FQDN=whatever.example.com -e EMAIL_FQDN=whatever.example.com -e MASTER_PASSWORD=SecretPassword -e LIST_ADMIN=whoever@example.com -p 49780:80 -p 25:25 drummerroma/mailman2:20.04-postfix
```
```
3. Run a production container, with exported volumes and support for German language:
```
docker run -d --restart=always --name my-mailing-list -h whatever.example.com -e URL_FQDN=whatever.example.com -e EMAIL_FQDN=whatever.example.com -e MASTER_PASSWORD=SecretPassword -e LIST_LANGUAGE_CODE=de -e LIST_LANGUAGE_NAME=German -e LIST_ADMIN=whoever@example.com -e DEBUG_CONTAINER=false -p 49780:80 -p 25:25 -v /my/local/dir/archives:/var/lib/mailman/archives -v /my/local/dir/lists:/var/lib/mailman/lists -v /my/local/dir/keys:/etc/exim4/tls.d -v /my/local/dir/log/apache2:/var/log/apache2 -v /my/local/dir/log/exim4:/var/log/exim4 -v /my/local/dir/log/mailman:/var/log/mailman drummerroma/mailman2:20.04-Postfix
docker run -d --restart=always --name my-mailing-list -h whatever.example.com -e URL_FQDN=whatever.example.com -e EMAIL_FQDN=whatever.example.com -e MASTER_PASSWORD=SecretPassword -e LIST_LANGUAGE_CODE=de -e LIST_LANGUAGE_NAME=German -e LIST_ADMIN=whoever@example.com -e DEBUG_CONTAINER=false -p 49780:80 -p 25:25 -v /my/local/dir/archives:/var/lib/mailman/archives -v /my/local/dir/lists:/var/lib/mailman/lists -v /my/local/dir/keys:/etc/exim4/tls.d -v /my/local/dir/log/apache2:/var/log/apache2 -v /my/local/dir/log/exim4:/var/log/exim4 -v /my/local/dir/log/mailman:/var/log/mailman drummerroma/mailman2:20.04-postfix
```
```
# Using docker-compose
Feel free to use this samples in your project.
docker-compose.yml
```
version: "3.7"
services:
mailman:
image: drummerroma/mailman2:20.04-postfix
container_name: mailman
hostname: ${EMAIL_HOST}
restart: unless-stopped
expose:
- "80"
- "25"
ports:
- "25:25"
- "80:80"
environment:
URL_FQDN: ${EMAIL_HOST}
EMAIL_FQDN: ${EMAIL_HOST}
LIST_ADMIN: ${LIST_ADMIN}
MASTER_PASSWORD: ${MASTER_PASSWORD}
LIST_LANGUAGE_CODE: 'de'
LIST_LANGUAGE_NAME: 'German'
DEBUG_CONTAINER: true
volumes:
- $PWD/data/lists:/var/lib/mailman/lists
- $PWD/data/archives:/var/lib/mailman/archives
- $PWD/data/dkim/:/etc/postfix/mailinglist.key
- $PWD/data/dkim/:/etc/postfix/mailinglist.txt
- $PWD/data/log/mailman:/var/log/mailman
- $PWD/data/log/apache2:/var/log/apache2
```
.env
```
URL_HOST=mailinglist.sample.org
EMAIL_HOST=mailinglist.sample.org
LIST_ADMIN=listadmin@sample.org
MASTER_PASSWORD=verystrongpassword
URL_PATTERN=http
URL_ROOT=lists/
```
# Persisting volumes on host
......@@ -169,4 +229,6 @@ This will create the host directories and set their permissions according to the
```
Restart your container after the permissions has been set on the host.
\ No newline at end of file
Restart your container after the permissions has been set on the host.
#!/bin/bash
if [ $DEBUG_CONTAINER == 'true' ]; then
outfile='/dev/console'
else
......@@ -34,13 +30,11 @@ echo ' Done.'
echo -n "Setting up DKIM..."
{
if [ ! -f /etc/postfix/mailinglist.key ]; then
opendkim-genkey -t -s mailinglist -d ${EMAIL_FQDN}
sleep 5
mv mailinglist.private /etc/postfix/mailinglist.key
mv mailinglist.txt /etc/postfix/mailinglist.txt
chmod 660 /etc/postfix/mailinglist.key
chown root:opendkim /etc/postfix/mailinglist.key
if [ ! -f /etc/dkimkeys/${DKIM_SELECTOR}.private ]; then
opendkim-genkey -t -D /etc/dkimkeys -d ${EMAIL_FQDN} -s ${DKIM_SELECTOR} -b 1024
sleep 5
chmod 660 /etc/dkimkeys/${DKIM_SELECTOR}.private
chown root:opendkim /etc/dkimkeys/${DKIM_SELECTOR}.private
fi
} &>$outfile
echo ' Done.'
......@@ -90,15 +84,13 @@ echo "smtpd_milters = inet:localhost:8891" >> /etc/postfix/main.cf
echo "non_smtpd_milters = inet:localhost:8891" >> /etc/postfix/main.cf
##### DKIM
/bin/sed -i "s/#SOCKET=inet:12345@localhost/SOCKET=inet:8891@localhost/" /etc/default/opendkim
/bin/sed -i "s/#Socket\ inet:8892@localhost/SOCKET=inet:8892@localhost/" /etc/opendkim.conf
echo "Domain ${EMAIL_FQDN}" >> /etc/opendkim.conf
echo "KeyFile /etc/postfix/mailinglist.key" >> /etc/opendkim.conf
echo "Selector mailinglist" >> /etc/opendkim.conf
echo "KeyFile /etc/dkimkey/${DKIM_SELECTOR}.key" >> /etc/opendkim.conf
echo "Selector ${DKIM_SELECTOR}" >> /etc/opendkim.conf
echo "Socket inet:8891@localhost" >> /etc/opendkim.conf
# Add some directives to Mailman config:
......@@ -113,13 +105,24 @@ echo 'SMTPPORT = 0' >> $mailmancfg
rm -f "${mailmancfg}c"
rm -f "/var/lib/mailman/Mailman/mm_cfg.pyc"
echo -n "Initializing mailing lists..."
echo -n "Mailman master password..."
{
/usr/sbin/mmsitepass ${MASTER_PASSWORD}
/usr/sbin/newlist -q -l ${LIST_LANGUAGE_CODE} mailman ${LIST_ADMIN} ${MASTER_PASSWORD}
} &>$outfile
echo ' Done.'
echo -n "Generate default mailman list if not exists.."
{
if [ ! -d /var/lib/mailman/lists/mailman ]; then
chown -R list:list /var/lib/mailman
/usr/sbin/newlist -q -l ${LIST_LANGUAGE_CODE} mailman ${LIST_ADMIN} ${MASTER_PASSWORD}
fi
}
echo ' Done.'
# Addaliases and update them:
cat << EOA >> /etc/aliases
mailman: "|/var/lib/mailman/mail/mailman post mailman"
......@@ -145,7 +148,7 @@ echo -n "Setting up Apache web server..."
echo -n "Fixing permissons and finishing setup..."
{
chown -R list:list /var/lib/mailman/
#chown -R list:list /var/lib/mailman/
/usr/lib/mailman/bin/check_perms -f
/usr/lib/mailman/bin/genaliases
} &>$outfile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment