Skip to content
Snippets Groups Projects
Commit fb1de3dd authored by Dariusz Janny's avatar Dariusz Janny
Browse files

Merge branch 'master' into 'master'

[faas#18] rebase faas-smtp and use Makefile

See merge request !2
parents 71c21ad9 06ba5073
No related branches found
No related tags found
1 merge request!2[edugain/faas#18] rebase faas-smtp and use Makefile
/.project
FROM alpine:3.12.3
FROM debian:10.7
RUN apk add --no-cache bash postfix supervisor rsyslog busybox-extras
ARG FAAS_SMTP_IMAGE
ARG FAAS_SMTP_NAME
ARG FAAS_SMTP_VERSION
COPY /conf/etc/supervisord.conf /etc/supervisord.conf
COPY /scripts/docker/run.sh /run.sh
RUN echo $FAAS_SMTP_IMAGE > /faas-docker-image
RUN echo $FAAS_SMTP_NAME > /faas-docker-name
RUN echo $FAAS_SMTP_VERSION > /faas-docker-version
RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set-selections && \
echo postfix postfix/mynetworks string "127.0.0.1/32" | debconf-set-selections && \
echo postfix postfix/mailname string $FAAS_SMTP_MYHOSTNAME | debconf-set-selections && \
apt-get -q -q update && \
apt-get install -y --no-install-recommends apt-utils && \
apt-get --yes install mailutils && \
apt-get --yes install postfix && \
apt-get --yes install telnet dnsutils && \
apt-get --yes install supervisor && \
apt-get --yes --no-install-recommends install rsyslog && \
apt-get clean
RUN \
postconf -e mydestination='$myhostname, localhost.$mydomain, localhost' && \
postconf -e smtpd_banner='$myhostname ESMTP $mail_name' && \
postconf -e unknown_local_recipient_reject_code='550' && \
postconf -e debug_peer_level='2' && \
postconf -e mail_owner='postfix' && \
postconf -e debug_peer_list='problem.domain' && \
postconf -# myhostname && \
postconf -# relayhost && \
postconf -# smtpd_relay_restrictions && \
postconf -# inet_protocols
COPY ./conf/etc/supervisord.conf /etc/supervisord.conf
COPY ./conf/etc/entrypoint /etc/entrypoint
COPY ./conf/etc/aliases /etc/aliases
EXPOSE 25/tcp
ENTRYPOINT ["/etc/entrypoint"]
EXPOSE 587
CMD [ "/bin/sh", "-c", "/run.sh" ]
Makefile 0 → 100644
# import config file
config ?= conf/faas-smtp.cnf
include $(config)
export $(shell sed 's/=.*//' $(config))
.DEFAULT_GOAL := help
build: # build container
docker build -t ${FAAS_SMTP_IMAGE} --build-arg FAAS_SMTP_NAME=${FAAS_SMTP_NAME} --build-arg FAAS_SMTP_IMAGE=${FAAS_SMTP_IMAGE} --build-arg FAAS_SMTP_VERSION=${FAAS_SMTP_VERSION} .
build-nc: # build container without caching
docker build --no-cache -t ${FAAS_SMTP_IMAGE} --build-arg FAAS_SMTP_NAME=${FAAS_SMTP_NAME} --build-arg FAAS_SMTP_IMAGE=${FAAS_SMTP_IMAGE} --build-arg FAAS_SMTP_VERSION=${FAAS_SMTP_VERSION} .
run: # run container
docker run -i -t --detach --rm --env-file=$(config) -p=${FAAS_SMTP_PORT}:25 --name="${FAAS_SMTP_NAME}" ${FAAS_SMTP_IMAGE}
run-nd: # run container in no-deamon mode
docker run -i -t --rm --env-file=$(config) -p=${FAAS_SMTP_PORT}:25 --name="${FAAS_SMTP_NAME}" ${FAAS_SMTP_IMAGE}
up: build run # build and run container
logs: # print docker logs
docker logs ${FAAS_SMTP_NAME}
stop: # stop container
docker stop ${FAAS_SMTP_NAME}
version: # print current component version
@echo ${FAAS_SMTP_VERSION}
help: # this help
@awk 'BEGIN {FS = ":.*?# "} /^[a-zA-Z_-]+:.*?# / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
......@@ -2,20 +2,32 @@
## structure
`_conf/`_ - directory with configuration files
`scripts/` - directory with utils and scripts
`test/` - directory with tests and utils
## build image
To build `faas-smtp` docker image
`
cd scripts/helpers && ./build.sh
make build
`
## run image
To run `faas-smtp` docker image
`
cd scripts/helpers && ./run.sh
make run
`
## additional commands
```
build build container
build-nc build container without caching
run run container
run-nd run container in no-deamon mode
up build and run container
logs print docker logs
stop stop container
version print current component version
```
#
# Aliases in this file will NOT be expanded in the header from
# Mail, but WILL be visible over networks or from /bin/mail.
#
# >>>>>>>>>> The program "newaliases" must be run after
# >> NOTE >> this file is updated for any changes to
# >>>>>>>>>> show through to sendmail.
#
# Basic system aliases -- these MUST be present.
mailer-daemon: postmaster
postmaster: root
# General redirections for pseudo accounts.
bin: root
daemon: root
adm: root
lp: root
sync: root
shutdown: root
halt: root
mail: root
news: root
uucp: root
operator: root
games: root
gopher: root
ftp: root
nobody: root
radiusd: root
nut: root
dbus: root
vcsa: root
canna: root
wnn: root
rpm: root
nscd: root
pcap: root
apache: root
webalizer: root
dovecot: root
fax: root
quagga: root
radvd: root
pvm: root
amanda: root
privoxy: root
ident: root
named: root
xfs: root
gdm: root
mailnull: root
postgres: root
sshd: root
smmsp: root
postfix: root
netdump: root
ldap: root
squid: root
ntp: root
mysql: root
desktop: root
rpcuser: root
rpc: root
nfsnobody: root
ingres: root
system: root
toor: root
manager: root
dumper: root
abuse: root
newsadm: news
newsadmin: news
usenet: news
ftpadm: ftp
ftpadmin: ftp
ftp-adm: ftp
ftp-admin: ftp
www: webmaster
webmaster: root
noc: root
security: root
hostmaster: root
info: postmaster
marketing: postmaster
sales: postmaster
support: postmaster
munin: root
# trap decode to catch security attacks
decode: root
# Person who should get root's mail
root: __FAAS_SMTP_ROOT_ALIASES_LIST__
#! /bin/bash
# set -x
# copy files to postfix jail location
cp -f /etc/services /var/spool/postfix/etc/services
cp -f /etc/resolv.conf /var/spool/postfix/etc/resolv.conf
# updating postfix mail aliases
sed -i "s/__FAAS_SMTP_ROOT_ALIASES_LIST__/$FAAS_SMTP_ROOT_ALIASES_LIST/g" /etc/aliases
postalias /etc/aliases
newaliases
sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
function update_postfix_config_value() {
local key=${1}
local value=${2}
......@@ -17,9 +27,13 @@ function update_postfix_config_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
[ -z "${FAAS_SMTP_INET_PROTOCOLS}" ] && echo "FAAS_SMTP_INET_PROTOCOLS is not set" && exit 1
update_postfix_config_value "myhostname" ${FAAS_SMTP_MYHOSTNAME}
update_postfix_config_value "inet_interfaces" ${FAAS_SMTP_INET_INTERFACES}
update_postfix_config_value "inet_protocols" ${FAAS_SMTP_INET_PROTOCOLS}
update_postfix_config_value "mynetworks" "${FAAS_SMTP_POSTFIX_MYNETWORKS}"
rm -f /var/spool/postfix/pid/master.pid
exec supervisord -c /etc/supervisord.conf
FAAS_SMTP_REPO=faas
FAAS_SMTP_NAME=faas-smtp
FAAS_SMTP_VERSION=1.0-SNAPSHOT
FAAS_SMTP_IMAGE=${FAAS_SMTP_REPO}/${FAAS_SMTP_NAME}:${FAAS_SMTP_VERSION}
FAAS_SMTP_MYHOSTNAME=test.faas.geant.net
FAAS_SMTP_INET_INTERFACES=all
FAAS_SMTP_INET_PROTOCOLS=all
FAAS_SMTP_PORT=9025
FAAS_SMTP_ROOT_ALIASES_LIST=janny@man.poznan.pl
FAAS_SMTP_POSTFIX_MYNETWORKS=127.0.0.1/32 192.168.0.0/16 172.16.0.0/12 172.17.0.0/16 10.0.0.0/8
\ No newline at end of file
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"
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
#! /bin/bash
docker-compose --env-file ../../conf/faas-smtp.env -f ../../conf/faas-smtp.compose.yml build
#! /bin/bash
docker-compose --env-file ../../conf/faas-smtp.env -f ../../conf/faas-smtp.compose.yml up
#! /usr/bin/perl
use warnings;
use strict;
use Net::SMTP;
my $smtpserver = 'localhost';
my $smtpport = 9025;
my $smtpuser = 'postfix';
my $smtppassword = '';
#my $to = 'janny@man.poznan.pl';
my $to = 'dariusz.janny@gmail.com';
my $from = 'root@test.faas.geant.net';
my $subject = 'subject no 2';
my $smtp = Net::SMTP->new($smtpserver, Port=>$smtpport, Timeout => 10, Debug => 1);
die "Could not connect to server!\n" unless $smtp;
# $smtp->auth($smtpuser, $smtppassword);
$smtp ->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("From: $from\n");
$smtp->datasend("To: $to\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("abc test\n");
$smtp->dataend();
$smtp->quit;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment