From cdcc41b281dccf061bfcb110259ab5c88724745c Mon Sep 17 00:00:00 2001 From: Dariusz Janny <janny@man.poznan.pl> Date: Mon, 21 Dec 2020 08:22:37 +0100 Subject: [PATCH] [#1] prepare image --- Dockerfile | 9 +++++++++ README.md | 19 +++++++++++++++++++ conf/etc/supervisord.conf | 23 +++++++++++++++++++++++ conf/faas-smtp.compose.yml | 14 ++++++++++++++ conf/faas-smtp.env | 6 ++++++ scripts/docker/run.sh | 25 +++++++++++++++++++++++++ scripts/helpers/build.sh | 3 +++ scripts/helpers/run.sh | 3 +++ 8 files changed, 102 insertions(+) create mode 100644 Dockerfile create mode 100644 conf/etc/supervisord.conf create mode 100644 conf/faas-smtp.compose.yml create mode 100644 conf/faas-smtp.env create mode 100755 scripts/docker/run.sh create mode 100755 scripts/helpers/build.sh create mode 100755 scripts/helpers/run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2867522 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:3.12.3 + +RUN apk add --no-cache bash postfix supervisor rsyslog busybox-extras + +COPY /conf/etc/supervisord.conf /etc/supervisord.conf +COPY /scripts/docker/run.sh /run.sh + +EXPOSE 587 +CMD [ "/bin/sh", "-c", "/run.sh" ] diff --git a/README.md b/README.md index 4c31e41..5615752 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # FaaS-SMTP +## structure +`_conf/`_ - directory with configuration files +`scripts/` - directory with utils and scripts + +## build image +To build `faas-smtp` docker image +` +cd scripts/helpers && ./build.sh +` + + +## run image +To run `faas-smtp` docker image +` +cd scripts/helpers && ./run.sh +` + + + diff --git a/conf/etc/supervisord.conf b/conf/etc/supervisord.conf new file mode 100644 index 0000000..dde262f --- /dev/null +++ b/conf/etc/supervisord.conf @@ -0,0 +1,23 @@ +[supervisord] +user = root +nodaemon = true +logfile = /dev/null +logfile_maxbytes= 0 + +[program:rsyslog] +command = rsyslogd -n +autostart = true +autorestart = true +startsecs = 2 +stopwaitsecs = 2 +stdout_logfile = /dev/stdout +stderr_logfile = /dev/stderr +stdout_logfile_maxbytes = 0 +stderr_logfile_maxbytes = 0 + +[program:postfix] +command = /usr/sbin/postfix -c /etc/postfix start-fg +autostart = true +autorestart = false +directory = /etc/postfix +startsecs = 0 diff --git a/conf/faas-smtp.compose.yml b/conf/faas-smtp.compose.yml new file mode 100644 index 0000000..7bbf43f --- /dev/null +++ b/conf/faas-smtp.compose.yml @@ -0,0 +1,14 @@ +version: '3.1' + +services: + smtp: + image: ${FAAS_SMTP_IMAGE} + build: + context: ../ + dockerfile: Dockerfile + restart: always + environment: + - FAAS_SMTP_MYHOSTNAME=${FAAS_SMTP_MYHOSTNAME} + - FAAS_SMTP_INET_INTERFACES=${FAAS_SMTP_INET_INTERFACES} + ports: + - "${FAAS_SMTP_PORT}:25" diff --git a/conf/faas-smtp.env b/conf/faas-smtp.env new file mode 100644 index 0000000..50a3ec6 --- /dev/null +++ b/conf/faas-smtp.env @@ -0,0 +1,6 @@ +FAAS_SMTP_IMAGE=faas/faas-smtp:1.0-SNAPSHOT + +FAAS_SMTP_MYHOSTNAME=test.faas.geant.net +FAAS_SMTP_INET_INTERFACES=all + +FAAS_SMTP_PORT=2025 diff --git a/scripts/docker/run.sh b/scripts/docker/run.sh new file mode 100755 index 0000000..e5c7362 --- /dev/null +++ b/scripts/docker/run.sh @@ -0,0 +1,25 @@ +#! /bin/bash + +# set -x + +sed -i '/imklog/s/^/#/' /etc/rsyslog.conf + +function update_postfix_config_value() { + local key=${1} + local value=${2} + local cfg_file=${3:-/etc/postfix/main.cf} + [ "${key}" == "" ] && echo "ERROR: Key is not set" && exit 1 + [ "${value}" == "" ] && echo "ERROR:value is not set" && exit 1 + + echo "Setting configuration option ${key} with value: ${value}" + postconf -e "${key} = ${value}" +} + +[ -z "${FAAS_SMTP_MYHOSTNAME}" ] && echo "FAAS_SMTP_MYHOSTNAME is not set" && exit 1 +[ -z "${FAAS_SMTP_INET_INTERFACES}" ] && echo "FAAS_SMTP_INET_INTERFACES is not set" && exit 1 + +update_postfix_config_value "myhostname" ${FAAS_SMTP_MYHOSTNAME} +update_postfix_config_value "inet_interfaces" ${FAAS_SMTP_INET_INTERFACES} + +rm -f /var/spool/postfix/pid/master.pid +exec supervisord -c /etc/supervisord.conf diff --git a/scripts/helpers/build.sh b/scripts/helpers/build.sh new file mode 100755 index 0000000..5865c48 --- /dev/null +++ b/scripts/helpers/build.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +docker-compose --env-file ../../conf/faas-smtp.env -f ../../conf/faas-smtp.compose.yml build diff --git a/scripts/helpers/run.sh b/scripts/helpers/run.sh new file mode 100755 index 0000000..1ad7967 --- /dev/null +++ b/scripts/helpers/run.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +docker-compose --env-file ../../conf/faas-smtp.env -f ../../conf/faas-smtp.compose.yml up -- GitLab