[DOCKER][MAIL] Substituted supervisord for s6

This commit is contained in:
Pastilhas 2020-11-22 19:14:59 +00:00 committed by Hugo Sales
parent def5e06a28
commit 0518bc2c6b
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
16 changed files with 65 additions and 77 deletions

View File

@ -90,6 +90,7 @@ services:
- ./docker/mail/mail.env
ports:
- 25:25
- 110:110
- 143:143
- 587:587
- 993:993

2
docker/mail/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
mail.env
config/*

View File

@ -15,9 +15,9 @@ RUN \
opendkim-tools \
openssl \
postfix \
procps \
rsyslog \
supervisor \
telnet \
s6 \
&& apt-get autoclean \
&& apt-get autoremove
@ -35,8 +35,18 @@ RUN \
# Copy config files
COPY rootfs/ /
RUN \
touch /etc/mail/aliases /etc/mail/domains /etc/mail/mailboxes /etc/mail/passwd \
&& postmap /etc/mail/aliases && postmap /etc/mail/domains && postmap /etc/mail/mailboxes
RUN \
chmod +x /etc/service/postfix/run \
&& chmod +x /etc/service/dovecot/run \
&& chmod +x /etc/service/opendkim/run \
&& chmod +x /etc/service/rsyslog/run
# Expose ports
EXPOSE 110 143 587 993 995
EXPOSE 25 110 143 587 993 995
# Run start script
ENTRYPOINT /usr/bin/start.sh

View File

Binary file not shown.

Binary file not shown.

View File

@ -1,8 +1,8 @@
protocols = imap pop3 lmtp
ssl = yes
ssl_cert = </etc/letsencrypt/live/social.org/fullchain.pem
ssl_key = </etc/letsencrypt/live/social.org/privkey.pem
ssl_cert =
ssl_key =
ssl_cipher_list = ALL:!LOW:!SSLv2:!EXP:!aNULL
listen = *, ::

View File

@ -7,7 +7,5 @@
::1
172.17.0.0/16
fe80::/64
social.org
#HOSTNAME
#host.example.com
#192.168.1.0/24

View File

@ -5,8 +5,8 @@ command_directory = /usr/sbin
daemon_directory = /usr/lib/postfix/sbin
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = %MAIL_HOSTNAME%
mydomain = %MAIL_HOSTNAME_FQDN%
myhostname =
mydomain =
myorigin = $myhostname
inet_interfaces = all
inet_protocols = all
@ -63,8 +63,8 @@ smtpd_sasl_local_domain = $mydomain
broken_sasl_auth_clients = yes
smtpd_tls_security_level = may
smtpd_tls_key_file = /etc/ssl/mail.key
smtpd_tls_cert_file = /etc/ssl/mail.crt
smtpd_tls_key_file =
smtpd_tls_cert_file =
smtpd_tls_loglevel = 1
smtpd_tls_session_cache_timeout = 3600s
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_tls_cache

View File

@ -1,46 +0,0 @@
[unix_http_server]
file=/tmp/supervisor.sock
[supervisord]
nodaemon=true
user=root
loglevel=warn
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock
user=root
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[program:opendkim]
autostart=false
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
command=/usr/sbin/opendkim -x /etc/mail/opendkim/opendkim.conf
[program:postfix]
autostart=false
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
command=postfix -c /etc/mail/postfix/postfix.conf
[program:dovecot]
autostart=false
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
command=dovecot -c /etc/mail/dovecot/dovecot.conf
[program:rsyslog]
autostart=false
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
command=rsyslog -f /etc/mail/rsyslogd/rsyslog.conf

View File

@ -0,0 +1,6 @@
#!/bin/sh
PID=$(pgrep dovecot)
if [ -z $PID ]
then
exec /usr/sbin/dovecot -c /etc/mail/dovecot/dovecot.conf
fi

View File

@ -0,0 +1,6 @@
#!/bin/sh
PID=$(pgrep opendkim)
if [ -z $PID ]
then
exec /usr/sbin/opendkim -x /etc/mail/opendkim/opendkim.conf
fi

View File

@ -0,0 +1,6 @@
#!/bin/sh
PID=$(pgrep master)
if [ -z $PID ]
then
exec /usr/sbin/postfix start -c /etc/mail/postfix
fi

View File

@ -0,0 +1,6 @@
#!/bin/sh
PID=$(pgrep rsyslog)
if [ -z $PID ]
then
exec /usr/sbin/rsyslogd -f /etc/mail/rsyslogd/rsyslog.conf
fi

View File

@ -17,15 +17,8 @@ fi
# Prepare postfix
if [ ! -d "/var/mail/$DOMAINNAME" ]
then
touch /etc/mail/aliases /etc/mail/domains /etc/mail/mailboxes /etc/mail/passwd
postmap /etc/mail/aliases && postmap /etc/mail/domains && postmap /etc/mail/mailboxes
/usr/bin/new-domain.sh "$DOMAINNAME"
fi
# Start services
rsyslogd -f /etc/mail/rsyslogd/rsyslog.conf
/usr/sbin/opendkim -x /etc/mail/opendkim/opendkim.conf
/usr/sbin/dovecot -c /etc/mail/dovecot/dovecot.conf
/usr/sbin/postfix start -c /etc/mail/postfix
supervisord -c /etc/mail/supervisord/supervisord.conf
# Run services
s6-svscan /etc/service

View File

@ -12,7 +12,7 @@ else
domain="${sub_domain}.${domain_root}"
fi
cat > mail.env <<EOF
cat > ./docker/mail/mail.env <<EOF
#!/bin/sh
DOMAINNAME=${domain_root}
MAILNAME=${domain}
@ -20,18 +20,24 @@ SSL_CERT=/etc/letsencrypt/live/${domain_root}/fullchain.pem
SSL_KEY=/etc/letsencrypt/live/${domain_root}/privkey.pem
EOF
DOMAINNAME="${domain_root}"
MAILNAME="${domain}"
SSL_CERT="/etc/letsencrypt/live/${domain_root}/fullchain.pem"
SSL_KEY="/etc/letsencrypt/live/${domain_root}/privkey.pem"
# Config postfix
sed -i -e "s#^\s*myhostname\s*=.*#myhostname = $MAILNAME#" rootfs/etc/mail/postfix/main.cf
sed -i -e "s#^\s*mydomain\s*=.*#mydomain = $DOMAINNAME#" rootfs/etc/mail/postfix/main.cf
sed -i -e "s#^\s*smtpd_tls_cert_file\s*=.*#smtpd_tls_cert_file = $SSL_CERT#" rootfs/etc/mail/postfix/main.cf
sed -i -e "s#^\s*smtpd_tls_key_file\s*=.*#smtpd_tls_key_file = $SSL_KEY#" rootfs/etc/mail/postfix/main.cf
sed -i -e "s#^\s*myhostname\s*=.*#myhostname = $MAILNAME#" ./docker/mail/config/postfix/main.cf
sed -i -e "s#^\s*mydomain\s*=.*#mydomain = $DOMAINNAME#" ./docker/mail/config/postfix/main.cf
sed -i -e "s#^\s*smtpd_tls_cert_file\s*=.*#smtpd_tls_cert_file = $SSL_CERT#" ./docker/mail/config/postfix/main.cf
sed -i -e "s#^\s*smtpd_tls_key_file\s*=.*#smtpd_tls_key_file = $SSL_KEY#" ./docker/mail/config/postfix/main.cf
# Config dovecot
sed -i -e "s#^\s*ssl_cert\s*=.*#ssl_cert = <$SSL_CERT#" rootfs/etc/mail/dovecot/dovecot.conf
sed -i -e "s#^\s*ssl_key\s*=.*#ssl_key = <$SSL_KEY#" rootfs/etc/mail/dovecot/dovecot.conf
sed -i -e "s#^\s*hostname\s*=.*#hostname = $MAILNAME#" rootfs/etc/mail/dovecot/dovecot.conf
sed -i -e "s#^\s*postmaster_address\s*=.*#postmaster_address = $POSTMASTER#" rootfs/etc/mail/dovecot/dovecot.conf
sed -i -e "s#^\s*ssl_cert\s*=.*#ssl_cert = <$SSL_CERT#" ./docker/mail/config/dovecot/dovecot.conf
sed -i -e "s#^\s*ssl_key\s*=.*#ssl_key = <$SSL_KEY#" ./docker/mail/config/dovecot/dovecot.conf
sed -i -e "s#^\s*postmaster_address\s*=.*#postmaster_address = postmaster@$DOMAINNAME#" ./docker/mail/config/dovecot/dovecot.conf
# Config dkim
sed -i -e "s/#HOSTNAME/$MAILNAME/" rootfs/etc/mail/opendkim/TrustedHosts
sed -i -e "s/^.*#HOSTNAME/$MAILNAME#HOSTNAME/" ./docker/mail/config/opendkim/TrustedHosts
# Prepare mail user
touch /etc/mail/aliases /etc/mail/domains /etc/mail/mailboxes /etc/mail/passwd