diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0354e97 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM node:latest + +ENV HOSTNAME=${HOSTNAME:-haraka} + +RUN apt-get update && apt-get upgrade -y && apt-get install -y supervisor certbot && \ + rm -rf /var/lib/apt/lists/* && \ + mkdir /var/log/supervisord && \ + groupadd -r haraka && \ + useradd --comment "Haraka Server User" \ + --home /haraka \ + --shell /bin/false \ + --gid haraka \ + -r \ + -m \ + haraka \ + && chown -R haraka:haraka /haraka + +COPY cron.sh /cron.sh +COPY haraka.sh /run.sh +COPY supervisord.conf /etc/supervisor/supervisord.conf + +RUN chmod +x /cron.sh /haraka.sh + +# Install and Haraka and it's plugins +USER node +ENV NPM_CONFIG_PREFIX=/home/node/.npm-global +ENV PATH=$PATH:/home/node/.npm-global/bin + +RUN npm -g install Haraka \ + && npm -g install haraka-plugin-rspamd + + +# Port 80 is used for LetsEncrypt +EXPOSE 25 80 587 + +VOLUME /haraka + +ENTRYPOINT ["/run.sh"] diff --git a/cron.sh b/cron.sh new file mode 100644 index 0000000..a5ce8d4 --- /dev/null +++ b/cron.sh @@ -0,0 +1,3 @@ +set -eu + +crond -m off diff --git a/haraka.sh b/haraka.sh new file mode 100644 index 0000000..fe1a387 --- /dev/null +++ b/haraka.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Generate config +if [ ! -f /haraka/config/smtp.ini ]; then + haraka -i /haraka +fi + +# Specify hostname +echo $HOSTNAME > /haraka/config/me + +haraka -c /haraka diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..d976741 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,22 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisord/supervisord.log +pidfile=/var/run/supervisord/supervisord.pid +childlogdir=/var/log/supervisord/ +logfile_maxbytes=50MB ; maximum size of logfile before rotation +logfile_backups=10 ; number of backed up logfiles +loglevel=error + +[program:haraka] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=/haraka.sh + +[program:cron] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=/cron.sh