diff --git a/Dockerfile b/Dockerfile index fca87ab..94ab1e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,6 +58,8 @@ RUN chown -R root:root /etc/postfix RUN newaliases RUN mkdir -m 1777 /var/log/procmail ADD ./etc/logrotate.procmail /etc/logrotate.d/procmail +RUN cp /etc/resolv.conf /var/spool/postfix/etc/ +RUN cp /etc/services /var/spool/postfix/etc/ # Build RT and extensions ADD ./scripts/installext.sh /src/installext.sh diff --git a/README b/README index 640fa8a..dda1886 100644 --- a/README +++ b/README @@ -30,7 +30,7 @@ Run a one-off container to configure the database: docker run \ --link rtdb:db \ -e DATABASE_USER=rt_user \ - -e DATABASE_PASS=rt_pass \ + -e DATABASE_PASSWORD=rt_pass \ -e DATABASE_NAME=rt4 \ nickstenning/rt \ /usr/bin/rtinit @@ -42,7 +42,7 @@ Now the database is initialised and you can run RT proper: -p 25 \ -p 80 \ -e DATABASE_USER=rt_user \ - -e DATABASE_PASS=rt_pass \ + -e DATABASE_PASSWORD=rt_pass \ -e DATABASE_NAME=rt4 \ nickstenning/rt @@ -58,7 +58,7 @@ You can provide the DATABASE_HOST directly: -p 80 \ -e DATABASE_HOST=dbserver \ -e DATABASE_USER=rt_user \ - -e DATABASE_PASS=rt_pass \ + -e DATABASE_PASSWORD=rt_pass \ -e DATABASE_NAME=rt4 \ nickstenning/rt @@ -66,4 +66,10 @@ configuration ------------- This image provides some limited support for customising the deployment using -environment variables. See RT_SiteConfig.pm for details. +environment variables. See RT_SiteConfig.pm for the various variables which, +can be defined to configure how the container starts up + +By default the postfix within the container will be set to relay (relay_host), +ail to containers gateway IP address, to redefine `relay_host` use: + + -e RELAY_IP='some.ip.goes.here' diff --git a/etc/postfix/main.cf b/etc/postfix/main.cf index 124640a..fdd1a96 100644 --- a/etc/postfix/main.cf +++ b/etc/postfix/main.cf @@ -1,10 +1,32 @@ -myhostname = rt.example.org -mydomain = example.org -myorigin = $myhostname +mail_owner = postfix +myhostname = WEB_DOMAIN +mydomain = WEB_DOMAIN +myorigin = WEB_DOMAIN inet_interfaces = all mydestination = $myhostname unknown_local_recipient_reject_code = 550 -relayhost = mailrelay.example.org +relayhost = RELAY_IP +relay_domains = + WEB_DOMAIN alias_maps = hash:/etc/postfix/aliases alias_database = hash:/etc/postfix/aliases -recipient_delimiter = - +mailman_destination_recipient_limit=1 +smtpd_helo_restrictions = + reject_non_fqdn_hostname, + reject_invalid_hostname, + permit +smtpd_sender_restrictions = + permit_mynetworks, + reject_non_fqdn_sender, + reject_unknown_sender_domain, + permit +smtpd_recipient_restrictions = + permit_mynetworks, + reject_unauth_pipelining, + reject_non_fqdn_recipient, + reject_unknown_recipient_domain, + reject_invalid_hostname, + reject_unauth_destination, + reject_rbl_client sbl-xbl.spamhaus.org, + permit + diff --git a/etc/postfix/procmailrc.rt b/etc/postfix/procmailrc.rt index 261df61..5e971ac 100644 --- a/etc/postfix/procmailrc.rt +++ b/etc/postfix/procmailrc.rt @@ -4,7 +4,7 @@ LOGFILE=/var/log/procmail/rt.log #Messages >300000 characters proceed to recipient (unlikely to be spam) :0w * > 300000 -| rt-mailgate --queue $QUEUE --action $ACTION --url http://rt.example.org/ +| rt-mailgate --queue $QUEUE --action $ACTION --url http://WEB_DOMAIN/ :0w * ^X-RT-Loop-Prevention: example.org @@ -18,8 +18,8 @@ LOGFILE=/var/log/procmail/rt.log #if the spam trigger is fired send to spam queue :0w * ^X-spam-Status: Yes -| rt-mailgate --queue spam --action correspond --url http://rt.example.org/ +| rt-mailgate --queue spam --action correspond --url http://WEB_DOMAIN/ #if the spam trigger is not fired then send to expected destination :0w -| rt-mailgate --queue $QUEUE --action $ACTION --url http://rt.example.org/ +| rt-mailgate --queue $QUEUE --action $ACTION --url http://WEB_DOMAIN/ diff --git a/svc/postfix/run b/svc/postfix/run index 136893b..4018a90 100755 --- a/svc/postfix/run +++ b/svc/postfix/run @@ -1,11 +1,17 @@ #!/bin/sh exec 2>&1 -command_directory=$(postconf -h command_directory) -daemon_directory=$("$command_directory"/postconf -h daemon_directory) -# make consistency check -"$command_directory"/postfix check +#these are expected to be passed in via docker -e +if [ -z ${RELAY_IP} ]; +then + RELAY_IP=$(route -n | awk /UG/'{print $2}' | head -1) +fi -# run Postfix -exec "$daemon_directory"/master +sed -e "s/RELAY_IP/${RELAY_IP}/g" -i /etc/postfix/main.cf +sed -e "s/WEB_DOMAIN/${WEB_DOMAIN}/g" -i /etc/postfix/main.cf +sed -e "s/WEB_DOMAIN/${WEB_DOMAIN}/g" -i /etc/postfix/procmailrc.rt + +service postfix start +sleep 5 +exec tail -F /var/log/mail.log