From d4025fb90ab6caa0a06a171335748884b8420d93 Mon Sep 17 00:00:00 2001 From: Chris Blake Date: Mon, 22 Oct 2018 20:29:26 -0500 Subject: [PATCH 1/2] Update Base to Alpine 3.8 * Update base image to Alpine 3.8 * Install s6 process manager directly * Upgraded BATS to 1.1.0 * Install syslog-ng for postfix logging to stdout --- Dockerfile | 20 +++++++++++++++----- install/postfix.sh | 2 -- install/syslog-ng.conf | 37 +++++++++++++++++++++++++++++++++++++ install/syslog-ng.sh | 3 +++ 4 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 install/syslog-ng.conf create mode 100644 install/syslog-ng.sh diff --git a/Dockerfile b/Dockerfile index dbf3458..ad486af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,37 @@ -FROM sillelien/base-alpine:0.10 +FROM alpine:3.8 LABEL maintainer="Zhuohuan LI " -ENV BATS_VERSION 0.4.0 +ENV BATS_VERSION 1.1.0 +ENV S6_VERSION 1.21.7.0 ## Install System RUN apk add --update --no-cache \ bash \ curl \ + cyrus-sasl \ drill \ logrotate \ openssl \ postfix \ - cyrus-sasl \ + syslog-ng \ \ && curl -s -o "/tmp/v${BATS_VERSION}.tar.gz" -L \ - "https://github.com/sstephenson/bats/archive/v${BATS_VERSION}.tar.gz" \ + "https://github.com/bats-core/bats-core/archive/v${BATS_VERSION}.tar.gz" \ && tar -xzf "/tmp/v${BATS_VERSION}.tar.gz" -C /tmp/ \ - && bash "/tmp/bats-${BATS_VERSION}/install.sh" /usr/local \ + && bash "/tmp/bats-core-${BATS_VERSION}/install.sh" /usr/local \ \ && rm -rf /tmp/* +## Install s6 process manager +RUN curl -L -s https://github.com/just-containers/s6-overlay/releases/download/v${S6_VERSION}/s6-overlay-amd64.tar.gz \ + | tar xzf - -C / + ## Configure Service COPY install/main.dist.cf /etc/postfix/main.cf COPY install/master.dist.cf /etc/postfix/master.cf +COPY install/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf RUN cat /dev/null > /etc/postfix/aliases && newaliases \ && echo simple-mail-forwarder.com > /etc/hostname \ @@ -43,6 +50,9 @@ RUN bash -n /app/init-openssl.sh && chmod +x /app/init-openssl.sh COPY install/postfix.sh /etc/services.d/postfix/run RUN bash -n /etc/services.d/postfix/run && chmod +x /etc/services.d/postfix/run +COPY install/syslog-ng.sh /etc/services.d/syslog-ng/run +RUN bash -n /etc/services.d/syslog-ng/run && chmod +x /etc/services.d/syslog-ng/run + COPY entrypoint.sh /entrypoint.sh RUN bash -n /entrypoint.sh && chmod a+x /entrypoint.sh diff --git a/install/postfix.sh b/install/postfix.sh index ad329c2..85450cb 100755 --- a/install/postfix.sh +++ b/install/postfix.sh @@ -13,8 +13,6 @@ daemon_directory=`$command_directory/postconf -h daemon_directory` $daemon_directory/master -t || $command_directory/postfix stop # make consistency check -chown root /var/spool/postfix -chown root /var/spool/postfix/pid $command_directory/postfix check >/dev/console 2>&1 # run Postfix diff --git a/install/syslog-ng.conf b/install/syslog-ng.conf new file mode 100644 index 0000000..6c499b1 --- /dev/null +++ b/install/syslog-ng.conf @@ -0,0 +1,37 @@ +@version: 3.9 + +# Sources +source s_dgram { + unix-dgram("/dev/log"); + internal(); +}; + +# Filters +filter f_out { + level(info..warn); +}; +filter f_err { + level(err..emerg,debug); +}; + +# Destinations +destination d_stdout { + pipe("/dev/stdout"); +}; + +destination d_stderr { + pipe("/dev/stderr"); +}; + +# Logs +log { + source(s_dgram); + filter(f_out); + destination(d_stdout); +}; + +log { + source(s_dgram); + filter(f_err); + destination(d_stderr); +}; diff --git a/install/syslog-ng.sh b/install/syslog-ng.sh new file mode 100644 index 0000000..0d27460 --- /dev/null +++ b/install/syslog-ng.sh @@ -0,0 +1,3 @@ +#!/bin/execlineb -P + +/usr/sbin/syslog-ng --cfgfile=/etc/syslog-ng/syslog-ng.conf -F From 3fbe2623b99ce950345e866078bfae4247c9c670 Mon Sep 17 00:00:00 2001 From: Chris Blake Date: Mon, 22 Oct 2018 21:26:52 -0500 Subject: [PATCH 2/2] syslog-ng: Disable statistic messages These spam the console too much, so disable them. --- install/syslog-ng.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install/syslog-ng.conf b/install/syslog-ng.conf index 6c499b1..e8a96c8 100644 --- a/install/syslog-ng.conf +++ b/install/syslog-ng.conf @@ -1,5 +1,11 @@ @version: 3.9 +# Options +options { + # Disable statistic log messages. + stats_freq(0); +}; + # Sources source s_dgram { unix-dgram("/dev/log");