Browse Source

refactor: move CMD to serve.sh

Fabian Peter Hammerle 5 years ago
parent
commit
f5ff0eb7bd
2 changed files with 14 additions and 4 deletions
  1. 2 4
      Dockerfile
  2. 12 0
      serve.sh

+ 2 - 4
Dockerfile

@@ -18,8 +18,6 @@ RUN postfix check
 
 ENV POSTFIX_RELAYHOST ""
 ENV POSTFIX_RELAY_DOMAINS ""
+COPY serve.sh /
 # TODO run as unprivileged user?
-CMD postconf -ev relayhost="$POSTFIX_RELAYHOST" \
- && postconf -ev relay_domains="$POSTFIX_RELAY_DOMAINS" \
- && postconf -ev syslog_name="$HOSTNAME/pstfx" \
- && postfix start-fg
+CMD ["/serve.sh"]

+ 12 - 0
serve.sh

@@ -0,0 +1,12 @@
+#!/bin/sh
+
+function set_option {
+    (set -x; postconf -evv "$1=$2")
+}
+
+[ -z "$POSTFIX_RELAYHOST" ] || set_option relayhost "$POSTFIX_RELAYHOST"
+[ -z "$POSTFIX_RELAY_DOMAINS" ] || set_option relay_domains "$POSTFIX_RELAY_DOMAINS"
+set_option syslog_name "$(hostname)/pstfx"
+
+set -x
+exec postfix start-fg