Get rid of hard coded IPs (#441)

Replace them with:
* containers' hostnames
* gateway's IP address for default SMTP_HOST
* Core: when SMTP_HOST undef, echo the default value
* docker-compose: add port mapping
* docker-compose: drop network driver conf
* Exim macro: use localhost as LMTP host
* Update README.md
* docker-compose: Limit port mapping to loopback
* Update other docker-compose example files
This commit is contained in:
pini-gh
2021-03-15 18:47:13 +01:00
committed by GitHub
parent dcc130678f
commit c10aa6fce4
13 changed files with 75 additions and 65 deletions

View File

@@ -40,8 +40,8 @@ These are the variables that you MUST change before deploying:
These are the variables that you don't need to change if you are using a
standard version of docker-compose.yaml from this repository.
- `MM_HOSTNAME`: Which IP should Core bind to for REST API and LMTP. If not
defined output for `hostname -i` command is used.
- `MM_HOSTNAME`: Which hostname or IP should Core bind to for REST API and
LMTP. If not defined output from `hostname` command is used.
- `MAILMAN_REST_PORT`: Which port should Core use for the REST API. If not defined
the default is `8001`.
@@ -55,7 +55,8 @@ standard version of docker-compose.yaml from this repository.
- `MTA`: Mail Transfer Agent to use. Either `exim` or `postfix`. Default value is `exim`.
- `SMTP_HOST`: IP Address/hostname from which you will be sending
emails. Default value is `172.19.199.1`, which is the address of the Host OS.
emails. Default value is the container's gateway retrieved from:
/sbin/ip route | awk '/default/ { print $3 }'
- `SMTP_PORT`: Port used for SMTP. Default is `25`.

View File

@@ -2,7 +2,9 @@
# /etc/exim4/conf.d/main/25_mm3_macros
domainlist mm3_domains=MY_DOMAIN_NAME
MM3_LMTP_HOST=172.19.199.2
# Depending on your network configuration
#MM3_LMTP_HOST=mailman-core
MM3_LMTP_HOST=localhost
MM3_LMTP_PORT=8024
MM3_HOME=/opt/mailman/core/var

View File

@@ -27,14 +27,16 @@ function wait_for_mysql () {
echo "# This file is autogenerated at container startup." > /etc/mailman.cfg
# Check if $MM_HOSTNAME is set, if not, set it to the value returned by
# `hostname -i` command to set it to whatever IP address is assigned to the
# `hostname` command to set it to whatever hostname is assigned to the
# container.
if [[ ! -v MM_HOSTNAME ]]; then
export MM_HOSTNAME=`hostname -i`
export MM_HOSTNAME=`hostname`
fi
# SMTP_HOST defaults to the gateway
if [[ ! -v SMTP_HOST ]]; then
export SMTP_HOST='172.19.199.1'
export SMTP_HOST=$(/sbin/ip route | awk '/default/ { print $3 }')
echo "SMPT_HOST not specified, using the gateway ($SMTP_HOST) as default"
fi
if [[ ! -v SMTP_PORT ]]; then