Skip to content

Commit

Permalink
Merged migrate_to_alpine branch into master (issue #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanluisbaptiste committed Feb 3, 2021
2 parents d5012c2 + 1976cf8 commit 273beb0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
#ALWAYS_ADD_MISSING_HEADERS=yes

# Optional: This will rewrite the from address overwriting it with the specified address for all email being relayed.
#OVERWRITE_FROM="Your Name" <email@company.com>
#OVERWRITE_FROM="Your Name" <email@company.com>
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#Dockerfile for a Postfix email relay service
FROM centos:7
FROM alpine:3.13
MAINTAINER Juan Luis Baptiste juan.baptiste@gmail.com

RUN yum install -y epel-release && yum update -y && \
yum install -y cyrus-sasl cyrus-sasl-plain cyrus-sasl-md5 mailx \
perl supervisor postfix rsyslog \
&& rm -rf /var/cache/yum/* \
&& yum clean all
RUN sed -i -e "s/^nodaemon=false/nodaemon=true/" /etc/supervisord.conf
RUN sed -i -e 's/inet_interfaces = localhost/inet_interfaces = all/g' /etc/postfix/main.cf
RUN apk update && \
apk add bash gawk cyrus-sasl cyrus-sasl-login cyrus-sasl-crammd5 mailx \
perl supervisor postfix rsyslog && \
rm -rf /var/cache/apk/* && \
mkdir -p /var/log/supervisor/ /var/run/supervisor/ && \
sed -i -e 's/inet_interfaces = localhost/inet_interfaces = all/g' /etc/postfix/main.cf

COPY etc/ /etc/
COPY run.sh /
Expand Down
1 change: 1 addition & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: '2'
services:
postfix:
image: juanluisbaptiste/postfix:dev
build:
context: .
dockerfile: Dockerfile
2 changes: 1 addition & 1 deletion etc/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ nodaemon=true ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
;umask=022 ; (process file creation umask;default 022)
;user=chrism ; (default is current user, required if root)
user=root ; (default is current user, required if root)
;identifier=supervisor ; (supervisord identifier, default is 'supervisor')
;directory=/tmp ; (default is not to cd during start)
;nocleanup=true ; (don't clean up tempfiles at start;default false)
Expand Down
10 changes: 5 additions & 5 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
function add_config_value() {
local key=${1}
local value=${2}
local config_file=${3:-/etc/postfix/main.cf}
# local config_file=${3:-/etc/postfix/main.cf}
[ "${key}" == "" ] && echo "ERROR: No key set !!" && exit 1
[ "${value}" == "" ] && echo "ERROR: No value set !!" && exit 1

Expand All @@ -24,7 +24,7 @@ if [ -n "${SMTP_PASSWORD_FILE}" ]; then [ -f "${SMTP_PASSWORD_FILE}" ] && read S
SMTP_PORT="${SMTP_PORT:-587}"

#Get the domain from the server host name
DOMAIN=`echo ${SERVER_HOSTNAME} |awk -F. '{$1="";OFS="." ; print $0}' | sed 's/^.//'`
DOMAIN=`echo ${SERVER_HOSTNAME} | awk 'BEGIN{FS=OFS="."}{print $(NF-1),$NF}'`

# Set needed config options
add_config_value "myhostname" ${SERVER_HOSTNAME}
Expand All @@ -34,7 +34,7 @@ add_config_value "myorigin" '$mydomain'
add_config_value "relayhost" "[${SMTP_SERVER}]:${SMTP_PORT}"
add_config_value "smtp_use_tls" "yes"
add_config_value "smtp_sasl_auth_enable" "yes"
add_config_value "smtp_sasl_password_maps" "hash:/etc/postfix/sasl_passwd"
add_config_value "smtp_sasl_password_maps" "lmdb:/etc/postfix/sasl_passwd"
add_config_value "smtp_sasl_security_options" "noanonymous"
add_config_value "always_add_missing_headers" "${ALWAYS_ADD_MISSING_HEADERS:-no}"

Expand All @@ -53,7 +53,7 @@ if [ ! -f /etc/postfix/sasl_passwd ]; then
fi
fi

#Set header tag
#Set header tag
if [ ! -z "${SMTP_HEADER_TAG}" ]; then
postconf -e "header_checks = regexp:/etc/postfix/header_tag"
echo -e "/^MIME-Version:/i PREPEND RelayTag: $SMTP_HEADER_TAG\n/^Content-Transfer-Encoding:/i PREPEND RelayTag: $SMTP_HEADER_TAG" > /etc/postfix/header_tag
Expand Down Expand Up @@ -86,4 +86,4 @@ fi
# starting services
rm -f /var/spool/postfix/pid/master.pid

exec supervisord
exec supervisord -c /etc/supervisord.conf

0 comments on commit 273beb0

Please sign in to comment.