Skip to content

Commit b0be083

Browse files
authored
Feature/spamassassin alpine (#25)
spamassassin: - Switched from Debian to Alpine - Simplified start up and configuration
1 parent 3e9428c commit b0be083

File tree

8 files changed

+60
-74
lines changed

8 files changed

+60
-74
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ logs:
3737
$(compose-production) logs mda
3838
$(compose-production) logs web
3939
$(compose-production) logs db
40+
$(compose-production) logs spamassassin

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ services:
3333
build: ./web
3434
restart: on-failure:5
3535
env_file: .env
36+
mem_limit: 128M
3637

3738
spamassassin:
3839
image: jeboehm/mailserver-spamassassin:latest
3940
build: ./spamassassin
4041
restart: on-failure:5
42+
mem_limit: 192M
4143

4244
volumes:
4345
data-db:

spamassassin/Dockerfile

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
1-
FROM debian:jessie
1+
FROM alpine:3.6
22
MAINTAINER Jeffrey Boehm "[email protected]"
33

4-
RUN apt-get update && \
5-
apt-get install -y --no-install-recommends \
6-
supervisor \
7-
spamassassin \
8-
pyzor \
9-
razor \
10-
spamass-milter && \
11-
rm -rf /var/lib/apt/lists/*
4+
ENV SPAMASS_USER=spamass \
5+
SPAMASS_GROUP=spamass \
6+
SPAMASS_CONF=/var/lib/spamassassin \
7+
SA_HOME=/var/lib/spamassassin/.spamassassin \
8+
SA_PORT=1783
9+
10+
RUN apk --no-cache add \
11+
libgcc \
12+
libmilter-dev \
13+
libstdc++ \
14+
openssl \
15+
perl-mail-spf \
16+
python3 \
17+
razor \
18+
spamassassin \
19+
spamassassin-client \
20+
supervisor \
21+
wget && \
22+
apk --no-cache add --virtual .fetch-deps \
23+
autoconf \
24+
automake \
25+
build-base && \
26+
pip3 install \
27+
pyzor && \
28+
wget https://github.com/andybalholm/spamass-milter/archive/master.tar.gz && \
29+
tar -xvf master.tar.gz && \
30+
cd spamass-milter-master && \
31+
./autogen.sh && \
32+
make && \
33+
make install && \
34+
cd / && \
35+
rm -rf spamass-milter-master master.tar.gz && \
36+
apk del .fetch-deps && \
37+
addgroup -S ${SPAMASS_GROUP} && \
38+
adduser -D ${SPAMASS_USER} -G ${SPAMASS_GROUP} && \
39+
chgrp ${SPAMASS_GROUP} ${SPAMASS_CONF} && \
40+
chmod 775 ${SPAMASS_CONF}
41+
42+
USER ${SPAMASS_USER}
43+
VOLUME ["${SPAMASS_CONF}"]
1244

1345
COPY rootfs/ /
1446

1547
EXPOSE 9999
1648

17-
VOLUME /var/lib/spamassassin
18-
49+
HEALTHCHECK CMD spamc -K -p ${SA_PORT} || exit 1
1950
CMD ["/usr/bin/supervisord"]

spamassassin/rootfs/etc/spamassassin/local.cf

Lines changed: 0 additions & 9 deletions
This file was deleted.

spamassassin/rootfs/etc/supervisor/conf.d/supervisord.conf renamed to spamassassin/rootfs/etc/supervisord.conf

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,22 @@
22
nodaemon=true
33
logfile=/dev/stderr
44
logfile_maxbytes=0
5-
pidfile=/var/run/supervisord.pid
5+
pidfile=/tmp/supervisord.pid
66

77
[program:sa-update]
88
command=/usr/local/bin/sa-update.sh
99
redirect_stderr=true
1010
stdout_logfile=/dev/stderr
1111
stdout_logfile_maxbytes=0
12-
stderr_logfile=/dev/stderr
13-
stderr_logfile_maxbytes=0
1412

1513
[program:spamd]
1614
command=/usr/local/bin/spamd.sh
1715
redirect_stderr=true
1816
stdout_logfile=/dev/stderr
1917
stdout_logfile_maxbytes=0
20-
stderr_logfile=/dev/stderr
21-
stderr_logfile_maxbytes=0
2218

2319
[program:spamass-milter]
24-
command=spamass-milter -p inet:[email protected] -u spamass-milter
20+
command=spamass-milter -p inet:[email protected] -- -p %(ENV_SA_PORT)s
2521
redirect_stderr=true
2622
stdout_logfile=/dev/stderr
2723
stdout_logfile_maxbytes=0
28-
stderr_logfile=/dev/stderr
29-
stderr_logfile_maxbytes=0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
echo asd > /tmp/spam
4+
spamassassin -t -D < /tmp/spam
5+
rm /tmp/spam

spamassassin/rootfs/usr/local/bin/sa-update.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#!/bin/sh
2-
3-
PIDFILE="/run/spamd.pid"
2+
PIDFILE="${SA_HOME}/spamd.pid"
43

54
do_update() {
6-
start-stop-daemon \
7-
--chuid debian-spamd:debian-spamd --start \
8-
--exec /usr/bin/sa-update -- \
9-
--gpghomedir /var/lib/spamassassin/sa-update-keys 2>&1
5+
/usr/bin/sa-update \
6+
--gpghomedir ${SA_HOME}/sa-update-keys 2>&1
107
}
118

129
do_reload() {
Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,12 @@
11
#!/bin/sh
2-
SA_HOME="/var/lib/spamassassin/.spamassassin"
3-
PYZOR_HOME="/var/lib/spamassassin/.pyzor"
4-
RAZOR_HOME="/var/lib/spamassassin/.razor"
52
echo "Starting spamassassin.."
63

7-
create_homedir() {
8-
if ! [ -d ${SA_HOME} ]
9-
then
10-
mkdir ${SA_HOME}
11-
chown debian-spamd ${SA_HOME}
12-
fi
13-
}
14-
15-
pyzor_discover() {
16-
start-stop-daemon \
17-
--chuid debian-spamd:debian-spamd --start \
18-
--exec /usr/bin/pyzor -- \
19-
--homedir ${PYZOR_HOME} discover
20-
}
21-
22-
razor_setup() {
23-
if [ -d ${RAZOR_HOME} ]
24-
then
25-
return 0
26-
fi
27-
28-
mkdir ${RAZOR_HOME}
29-
30-
razor-admin -home=${RAZOR_HOME} -register
31-
razor-admin -home=${RAZOR_HOME} -create
32-
razor-admin -home=${RAZOR_HOME} -discover
33-
}
34-
35-
create_homedir
36-
pyzor_discover
37-
razor_setup
38-
394
/usr/local/bin/sa-update.sh --startup
405

41-
spamd \
42-
--username=debian-spamd \
6+
/usr/sbin/spamd \
437
--syslog stderr \
44-
--pidfile=/run/spamd.pid \
8+
--pidfile=${SA_HOME}/spamd.pid \
459
--max-children 5 \
46-
--helper-home-dir \
47-
--nouser-config
10+
--helper-home-dir=${SA_HOME} \
11+
--nouser-config \
12+
--listen 127.0.0.1:${SA_PORT}

0 commit comments

Comments
 (0)