Moved cron tasks to another stack.

Added a second fetchmail.
Moved image building to startup script.
Moved volume management to startup script.
This commit is contained in:
yohan 2020-02-23 15:17:38 +01:00
parent 10fb8b003d
commit 9caefaa6d3
3 changed files with 34 additions and 39 deletions

11
crontab
View File

@ -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

View File

@ -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

View File

@ -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