diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..28675225a7347f8d43507bebca262c0c1b6d78c1 --- /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 4c31e4109eff3796b0b2bf54a06b012ed81397b8..56157527e132a16fa2b8c2cec22b93a1e1618bdb 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 0000000000000000000000000000000000000000..dde262fc696c25be674c922419b6a5f582d6c33f --- /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 0000000000000000000000000000000000000000..7bbf43fe646a5d0c841a68447f35a3003e4cf611 --- /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 0000000000000000000000000000000000000000..50a3ec69c28101a91687f6c1bdea8c76c0769641 --- /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 0000000000000000000000000000000000000000..e5c73624d5d3c59497a4420deea97ccbdc7ac96a --- /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 0000000000000000000000000000000000000000..5865c48ab735b48f8a0523773d2ab36132e61e14 --- /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 0000000000000000000000000000000000000000..1ad79678aa340b921e45f73117fd38707e812f77 --- /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