From 3ef4856abb333008667a6b5e81d0c823db80ad8b Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Mon, 15 Jul 2019 22:15:27 +0200 Subject: [PATCH] Changes to use secrets and git repos. --- docker-compose.yml | 21 +++++++++++++++++---- start_or_update.sh | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100755 start_or_update.sh diff --git a/docker-compose.yml b/docker-compose.yml index 3de61ae..7fed9d0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,9 @@ version: "2.1" services: dovecot: - image: dovecot + image: dovecot:$VERSION_DOVECOT + build: "https://git.scimetis.net/yohan/docker-dovecot.git" + container_name: dovecot restart: always ports: - 993:993/tcp @@ -13,21 +15,32 @@ services: volumes: - mail_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: - image: fetchmail + image: fetchmail:$VERSION_FETCHMAIL + build: "https://git.scimetis.net/yohan/docker-fetchmail.git" + container_name: fetchmail restart: always networks: - mailnet + volumes: + - ./fetchmailrc:/etc/fetchmailrc feed2imap: - image: feed2imap + image: feed2imap:$VERSION_FEED2IMAP + build: "https://git.scimetis.net/yohan/docker-feed2imap.git" + container_name: feed2imap restart: always networks: - mailnet + volumes: + - ./feed2imaprc:/root/feed2imaprc cron-purge-dovecot: - image: cron + image: cron:$VERSION_CRON + build: "https://git.scimetis.net/yohan/docker-cron.git" restart: always network_mode: "host" volumes: diff --git a/start_or_update.sh b/start_or_update.sh new file mode 100755 index 0000000..ea6762d --- /dev/null +++ b/start_or_update.sh @@ -0,0 +1,14 @@ +#!/bin/bash +test -f ~/secrets.tar.gz.enc || curl -o ~/secrets.tar.gz.enc https://cloud.scimetis.net/s/$KEY/download +openssl enc -aes-256-cbc -d -in ~/secrets.tar.gz.enc | tar -zxv --strip 2 secrets/docker-mail-stack/fetchmailrc \ +secrets/docker-mail-stack/users secrets/docker-mail-stack/15-lda.conf secrets/docker-mail-stack/feed2imaprc +sudo chown root. fetchmailrc users 15-lda.conf feed2imaprc +sudo chmod a-r feed2imaprc +# --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 ssh://git@git.scimetis.net:2222/yohan/docker-dovecot.git| head -1 | cut -f 1|cut -c -10) \ +VERSION_FETCHMAIL=$(git ls-remote ssh://git@git.scimetis.net:2222/yohan/docker-fetchmail.git| head -1 | cut -f 1|cut -c -10) \ +VERSION_FEED2IMAP=$(git ls-remote ssh://git@git.scimetis.net:2222/yohan/docker-feed2imap.git| head -1 | cut -f 1|cut -c -10) \ +VERSION_CRON=$(git ls-remote ssh://git@git.scimetis.net:2222/yohan/docker-cron.git| head -1 | cut -f 1|cut -c -10) \ + sudo -E bash -c 'docker-compose up -d --force-recreate' +# /!\ We cannot remove the secrets files or restarting the container would become impossible.