From 9caefaa6d37c1aa5d341b3dbe082c25991b7b1d5 Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sun, 23 Feb 2020 15:17:38 +0100 Subject: [PATCH] Moved cron tasks to another stack. Added a second fetchmail. Moved image building to startup script. Moved volume management to startup script. --- crontab | 11 ----------- docker-compose.yml | 37 +++++++++++++++++-------------------- start_or_update.sh | 25 +++++++++++++++++-------- 3 files changed, 34 insertions(+), 39 deletions(-) delete mode 100644 crontab diff --git a/crontab b/crontab deleted file mode 100644 index d0e389f..0000000 --- a/crontab +++ /dev/null @@ -1,11 +0,0 @@ -# /etc/crontab: system-wide crontab -# Unlike any other crontab you don't have to run the `crontab' -# command to install the new version when you edit this file -# and files in /etc/cron.d. These files also have username fields, -# that none of the other crontabs do. - -SHELL=/bin/sh -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin - -# m | h | day of month | month | day of week | user | command -30 0 * * * root docker -H tcp://127.0.0.1:2375 exec dovecot /root/dovecot_expire.sh > /proc/1/fd/2 2>&1 diff --git a/docker-compose.yml b/docker-compose.yml index 7fed9d0..972e181 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: dovecot: image: dovecot:$VERSION_DOVECOT - build: "https://git.scimetis.net/yohan/docker-dovecot.git" + #build: "https://git.scimetis.net/yohan/docker-dovecot.git" container_name: dovecot restart: always ports: @@ -13,24 +13,34 @@ services: networks: - mailnet volumes: - - mail_data:/home/yohan + - /mnt/volumes/mail_data/data:/home/yohan - ./dovecot_expire.sh:/root/dovecot_expire.sh - ./users:/etc/dovecot/users - ./15-lda.conf:/etc/dovecot/conf.d/15-lda.conf - fetchmail: + fetchmail-orange: image: fetchmail:$VERSION_FETCHMAIL - build: "https://git.scimetis.net/yohan/docker-fetchmail.git" - container_name: fetchmail + #build: "https://git.scimetis.net/yohan/docker-fetchmail.git" + container_name: fetchmail-orange restart: always networks: - mailnet volumes: - - ./fetchmailrc:/etc/fetchmailrc + - ./fetchmailrc-orange:/etc/fetchmailrc + + fetchmail-scimetis: + image: fetchmail:$VERSION_FETCHMAIL + #build: "https://git.scimetis.net/yohan/docker-fetchmail.git" + container_name: fetchmail-scimetis + restart: always + networks: + - mailnet + volumes: + - ./fetchmailrc-scimetis:/etc/fetchmailrc feed2imap: image: feed2imap:$VERSION_FEED2IMAP - build: "https://git.scimetis.net/yohan/docker-feed2imap.git" + #build: "https://git.scimetis.net/yohan/docker-feed2imap.git" container_name: feed2imap restart: always networks: @@ -38,20 +48,7 @@ services: volumes: - ./feed2imaprc:/root/feed2imaprc - cron-purge-dovecot: - image: cron:$VERSION_CRON - build: "https://git.scimetis.net/yohan/docker-cron.git" - restart: always - network_mode: "host" - volumes: - - ./crontab:/etc/crontab - networks: mailnet: external: true - -volumes: - - mail_data: - external: true diff --git a/start_or_update.sh b/start_or_update.sh index 89d0890..26e4a7a 100755 --- a/start_or_update.sh +++ b/start_or_update.sh @@ -6,14 +6,23 @@ secrets/docker-mail-stack/fetchmailrc-scimetis sudo chown root. fetchmailrc-orange fetchmailrc-scimetis users 15-lda.conf feed2imaprc sudo chmod a-r feed2imaprc -sudo chown root:root crontab -sudo chmod 644 crontab +unset VERSION_DOVECOT VERSION_FETCHMAIL VERSION_FEED2IMAP +VERSION_DOVECOT=$(git ls-remote https://git.scimetis.net/yohan/docker-dovecot.git| head -1 | cut -f 1|cut -c -10) +VERSION_FETCHMAIL=$(git ls-remote https://git.scimetis.net/yohan/docker-fetchmail.git| head -1 | cut -f 1|cut -c -10) +VERSION_FEED2IMAP=$(git ls-remote https://git.scimetis.net/yohan/docker-feed2imap.git| head -1 | cut -f 1|cut -c -10) -# --force-recreate is used to recreate container when crontab file has changed -unset VERSION_DOVECOT VERSION_FETCHMAIL VERSION_FEED2IMAP VERSION_CRON -VERSION_DOVECOT=$(git ls-remote https://git.scimetis.net/yohan/docker-dovecot.git| head -1 | cut -f 1|cut -c -10) \ -VERSION_FETCHMAIL=$(git ls-remote https://git.scimetis.net/yohan/docker-fetchmail.git| head -1 | cut -f 1|cut -c -10) \ -VERSION_FEED2IMAP=$(git ls-remote https://git.scimetis.net/yohan/docker-feed2imap.git| head -1 | cut -f 1|cut -c -10) \ -VERSION_CRON=$(git ls-remote https://git.scimetis.net/yohan/docker-cron.git| head -1 | cut -f 1|cut -c -10) \ +rm -rf ~/build +mkdir -p ~/build +git clone https://git.scimetis.net/yohan/docker-dovecot.git ~/build/docker-dovecot +sudo docker build -t dovecot:$VERSION_DOVECOT ~/build/docker-dovecot +git clone https://git.scimetis.net/yohan/docker-fetchmail.git ~/build/docker-fetchmail +sudo docker build -t fetchmail:$VERSION_FETCHMAIL ~/build/docker-fetchmail +git clone https://git.scimetis.net/yohan/docker-feed2imap.git ~/build/docker-feed2imap +sudo docker build -t feed2imap:$VERSION_FEED2IMAP ~/build/docker-feed2imap +VERSION_DOVECOT=$VERSION_DOVECOT \ +VERSION_FETCHMAIL=$VERSION_FETCHMAIL \ +VERSION_FEED2IMAP=$VERSION_FEED2IMAP \ sudo -E bash -c 'docker-compose up -d --force-recreate' +# --force-recreate is used to recreate container when a file has changed # /!\ We cannot remove the secrets files or restarting the container would become impossible. +rm -rf ~/build