Skip to content

Commit

Permalink
Feature/spamassassin alpine (#25)
Browse files Browse the repository at this point in the history
spamassassin:
- Switched from Debian to Alpine
- Simplified start up and configuration
  • Loading branch information
jeboehm authored Aug 9, 2017
1 parent 3e9428c commit b0be083
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 74 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ logs:
$(compose-production) logs mda
$(compose-production) logs web
$(compose-production) logs db
$(compose-production) logs spamassassin
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ services:
build: ./web
restart: on-failure:5
env_file: .env
mem_limit: 128M

spamassassin:
image: jeboehm/mailserver-spamassassin:latest
build: ./spamassassin
restart: on-failure:5
mem_limit: 192M

volumes:
data-db:
Expand Down
53 changes: 42 additions & 11 deletions spamassassin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
FROM debian:jessie
FROM alpine:3.6
MAINTAINER Jeffrey Boehm "[email protected]"

RUN apt-get update && \
apt-get install -y --no-install-recommends \
supervisor \
spamassassin \
pyzor \
razor \
spamass-milter && \
rm -rf /var/lib/apt/lists/*
ENV SPAMASS_USER=spamass \
SPAMASS_GROUP=spamass \
SPAMASS_CONF=/var/lib/spamassassin \
SA_HOME=/var/lib/spamassassin/.spamassassin \
SA_PORT=1783

RUN apk --no-cache add \
libgcc \
libmilter-dev \
libstdc++ \
openssl \
perl-mail-spf \
python3 \
razor \
spamassassin \
spamassassin-client \
supervisor \
wget && \
apk --no-cache add --virtual .fetch-deps \
autoconf \
automake \
build-base && \
pip3 install \
pyzor && \
wget https://github.com/andybalholm/spamass-milter/archive/master.tar.gz && \
tar -xvf master.tar.gz && \
cd spamass-milter-master && \
./autogen.sh && \
make && \
make install && \
cd / && \
rm -rf spamass-milter-master master.tar.gz && \
apk del .fetch-deps && \
addgroup -S ${SPAMASS_GROUP} && \
adduser -D ${SPAMASS_USER} -G ${SPAMASS_GROUP} && \
chgrp ${SPAMASS_GROUP} ${SPAMASS_CONF} && \
chmod 775 ${SPAMASS_CONF}

USER ${SPAMASS_USER}
VOLUME ["${SPAMASS_CONF}"]

COPY rootfs/ /

EXPOSE 9999

VOLUME /var/lib/spamassassin

HEALTHCHECK CMD spamc -K -p ${SA_PORT} || exit 1
CMD ["/usr/bin/supervisord"]
9 changes: 0 additions & 9 deletions spamassassin/rootfs/etc/spamassassin/local.cf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,22 @@
nodaemon=true
logfile=/dev/stderr
logfile_maxbytes=0
pidfile=/var/run/supervisord.pid
pidfile=/tmp/supervisord.pid

[program:sa-update]
command=/usr/local/bin/sa-update.sh
redirect_stderr=true
stdout_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:spamd]
command=/usr/local/bin/spamd.sh
redirect_stderr=true
stdout_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:spamass-milter]
command=spamass-milter -p inet:[email protected] -u spamass-milter
command=spamass-milter -p inet:[email protected] -- -p %(ENV_SA_PORT)s
redirect_stderr=true
stdout_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
5 changes: 5 additions & 0 deletions spamassassin/rootfs/usr/local/bin/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

echo asd > /tmp/spam
spamassassin -t -D < /tmp/spam
rm /tmp/spam
9 changes: 3 additions & 6 deletions spamassassin/rootfs/usr/local/bin/sa-update.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#!/bin/sh

PIDFILE="/run/spamd.pid"
PIDFILE="${SA_HOME}/spamd.pid"

do_update() {
start-stop-daemon \
--chuid debian-spamd:debian-spamd --start \
--exec /usr/bin/sa-update -- \
--gpghomedir /var/lib/spamassassin/sa-update-keys 2>&1
/usr/bin/sa-update \
--gpghomedir ${SA_HOME}/sa-update-keys 2>&1
}

do_reload() {
Expand Down
45 changes: 5 additions & 40 deletions spamassassin/rootfs/usr/local/bin/spamd.sh
Original file line number Diff line number Diff line change
@@ -1,47 +1,12 @@
#!/bin/sh
SA_HOME="/var/lib/spamassassin/.spamassassin"
PYZOR_HOME="/var/lib/spamassassin/.pyzor"
RAZOR_HOME="/var/lib/spamassassin/.razor"
echo "Starting spamassassin.."

create_homedir() {
if ! [ -d ${SA_HOME} ]
then
mkdir ${SA_HOME}
chown debian-spamd ${SA_HOME}
fi
}

pyzor_discover() {
start-stop-daemon \
--chuid debian-spamd:debian-spamd --start \
--exec /usr/bin/pyzor -- \
--homedir ${PYZOR_HOME} discover
}

razor_setup() {
if [ -d ${RAZOR_HOME} ]
then
return 0
fi

mkdir ${RAZOR_HOME}

razor-admin -home=${RAZOR_HOME} -register
razor-admin -home=${RAZOR_HOME} -create
razor-admin -home=${RAZOR_HOME} -discover
}

create_homedir
pyzor_discover
razor_setup

/usr/local/bin/sa-update.sh --startup

spamd \
--username=debian-spamd \
/usr/sbin/spamd \
--syslog stderr \
--pidfile=/run/spamd.pid \
--pidfile=${SA_HOME}/spamd.pid \
--max-children 5 \
--helper-home-dir \
--nouser-config
--helper-home-dir=${SA_HOME} \
--nouser-config \
--listen 127.0.0.1:${SA_PORT}

0 comments on commit b0be083

Please sign in to comment.