Skip to content

Commit

Permalink
Using supervisord to start services.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbck committed Feb 22, 2024
1 parent ce46632 commit b9f8979
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
4 changes: 4 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN apt-get update \
sqlite3 \
ssl-cert \
telnet \
supervisor \
&& rm -rf /var/lib/apt/lists/*

ENV MAILTRAP_USER mailtrap
Expand Down Expand Up @@ -62,6 +63,9 @@ RUN mkdir -p /var/lib/roundcube/db && \
# API
COPY root/usr/share/roundcube/api.php /usr/share/roundcube/

# Supervisord
COPY root/etc/supervisor/conf.d/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

COPY root/docker-entrypoint.sh /
RUN chmod 777 /docker-entrypoint.sh

Expand Down
25 changes: 18 additions & 7 deletions build/root/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
#!/usr/bin/env bash
set -e

# ln_if_file_exists src dest
function ln_if_file_exists () {
if [ -e "$1" ]; then
ln -sf "$1" "$2"
fi
}

# Symlink logfiles
ln_if_file_exists "/dev/null" "/var/log/mail.err"
ln_if_file_exists "/dev/null" "/var/log/mail.info"
ln_if_file_exists "/dev/null" "/var/log/mail.log"
ln_if_file_exists "/dev/null" "/var/log/mail.warn"
#ln_if_file_exists "/dev/null" "/var/log/auth.log"
ln_if_file_exists "/proc/1/fd/1" "/var/log/auth.log"
ln_if_file_exists "/proc/1/fd/1" "/var/log/syslog"

# Setup roundcube des_key
RC_DES_KEY=`cat /dev/urandom | head -n 256 | sha256sum | awk '{print $1}'`;
Expand Down Expand Up @@ -38,10 +55,4 @@ newaliases
postmap /etc/postfix/transport

# Start services
service rsyslog start
service dovecot start
service postfix start
service php8.2-fpm start
service nginx start

touch /var/log/mail.err /var/log/mail.log && tail -f /var/log/mail.err /var/log/mail.log
/usr/bin/supervisord
25 changes: 25 additions & 0 deletions build/root/etc/supervisor/conf.d/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[supervisord]
user=root
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
user=root
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
autorestart=true

[program:rsyslog]
command=/usr/sbin/rsyslogd -n

[program:dovecot]
command=/usr/sbin/dovecot -c /etc/dovecot/dovecot.conf -F

[program:postfix]
command=/usr/sbin/postfix start-fg

[program:php8.2-fpm]
command=/usr/sbin/php-fpm8.2 --nodaemonize --fpm-config=/etc/php/8.2/fpm/pool.d/www.conf

[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
1 change: 0 additions & 1 deletion docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: "3"
services:
mailtrap:
image: dbck/mailtrap:latest
init: true
environment:
- TZ=Europe/Berlin
- MAILTRAP_USER=username
Expand Down

0 comments on commit b9f8979

Please sign in to comment.