From 5cc5b7c40a63105c9a01737de32e8724ddabd006 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Thu, 4 Oct 2018 11:48:56 +0300 Subject: [PATCH 01/28] Copied docs/compose/docker-compose.yml to tests/compose/run.yml Edit for test environment --- tests/compose/run.yml | 108 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 tests/compose/run.yml diff --git a/tests/compose/run.yml b/tests/compose/run.yml new file mode 100644 index 00000000..c1667db3 --- /dev/null +++ b/tests/compose/run.yml @@ -0,0 +1,108 @@ +version: '2' + +services: + + front: + image: mailu/nginx:$VERSION + restart: no + env_file: $ENV_FILE + ports: + - "$BIND_ADDRESS4:80:80" + - "$BIND_ADDRESS4:443:443" + - "$BIND_ADDRESS4:110:110" + - "$BIND_ADDRESS4:143:143" + - "$BIND_ADDRESS4:993:993" + - "$BIND_ADDRESS4:995:995" + - "$BIND_ADDRESS4:25:25" + - "$BIND_ADDRESS4:465:465" + - "$BIND_ADDRESS4:587:587" + - "$BIND_ADDRESS6:80:80" + - "$BIND_ADDRESS6:443:443" + - "$BIND_ADDRESS6:110:110" + - "$BIND_ADDRESS6:143:143" + - "$BIND_ADDRESS6:993:993" + - "$BIND_ADDRESS6:995:995" + - "$BIND_ADDRESS6:25:25" + - "$BIND_ADDRESS6:465:465" + - "$BIND_ADDRESS6:587:587" + volumes: + - "$ROOT/certs:/certs" + + redis: + image: redis:alpine + restart: no + volumes: + - "$ROOT/redis:/data" + + imap: + image: mailu/dovecot:$VERSION + restart: no + env_file: $ENV_FILE + volumes: + - "$ROOT/data:/data" + - "$ROOT/mail:/mail" + - "$ROOT/overrides:/overrides" + depends_on: + - front + + smtp: + image: mailu/postfix:$VERSION + restart: no + env_file: $ENV_FILE + volumes: + - "$ROOT/data:/data" + - "$ROOT/overrides:/overrides" + depends_on: + - front + + antispam: + image: mailu/rspamd:$VERSION + restart: no + env_file: $ENV_FILE + volumes: + - "$ROOT/filter:/var/lib/rspamd" + - "$ROOT/dkim:/dkim" + - "$ROOT/overrides/rspamd:/etc/rspamd/override.d" + depends_on: + - front + + antivirus: + image: mailu/$ANTIVIRUS:$VERSION + restart: no + env_file: $ENV_FILE + volumes: + - "$ROOT/filter:/data" + + webdav: + image: mailu/$WEBDAV:$VERSION + restart: no + env_file: $ENV_FILE + volumes: + - "$ROOT/dav:/data" + + admin: + image: mailu/admin:$VERSION + restart: no + env_file: $ENV_FILE + volumes: + - "$ROOT/data:/data" + - "$ROOT/dkim:/dkim" + - /var/run/docker.sock:/var/run/docker.sock:ro + depends_on: + - redis + + webmail: + image: "mailu/$WEBMAIL:$VERSION" + restart: no + env_file: $ENV_FILE + volumes: + - "$ROOT/webmail:/data" + depends_on: + - imap + + fetchmail: + image: mailu/fetchmail:$VERSION + restart: no + env_file: $ENV_FILE + volumes: + - "$ROOT/data:/data" From 0067d97f26094c6a79b7a51c9fa204578d28d2e3 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Thu, 4 Oct 2018 11:50:32 +0300 Subject: [PATCH 02/28] Copied docs/compose/.env to tests/compose/core.env --- tests/compose/core.env | 134 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 tests/compose/core.env diff --git a/tests/compose/core.env b/tests/compose/core.env new file mode 100644 index 00000000..9477448a --- /dev/null +++ b/tests/compose/core.env @@ -0,0 +1,134 @@ +# Mailu main configuration file +# +# Most configuration variables can be modified through the Web interface, +# these few settings must however be configured before starting the mail +# server and require a restart upon change. + +################################### +# Common configuration variables +################################### + +# Set this to the path where Mailu data and configuration is stored +ROOT=/mailu + +# Mailu version to run (1.0, 1.1, etc. or master) +VERSION=master + +# Set to a randomly generated 16 bytes string +SECRET_KEY=ChangeMeChangeMe + +# Address where listening ports should bind +BIND_ADDRESS4=127.0.0.1 +BIND_ADDRESS6=::1 + +# Main mail domain +DOMAIN=mailu.io + +# Hostnames for this server, separated with comas +HOSTNAMES=mail.mailu.io,alternative.mailu.io,yetanother.mailu.io + +# Postmaster local part (will append the main mail domain) +POSTMASTER=admin + +# Choose how secure connections will behave (value: letsencrypt, cert, notls, mail, mail-letsencrypt) +TLS_FLAVOR=cert + +# Authentication rate limit (per source IP address) +AUTH_RATELIMIT=10/minute;1000/hour + +# Opt-out of statistics, replace with "True" to opt out +DISABLE_STATISTICS=False + +################################### +# Optional features +################################### + +# Expose the admin interface (value: true, false) +ADMIN=false + +# Choose which webmail to run if any (values: roundcube, rainloop, none) +WEBMAIL=none + +# Dav server implementation (value: radicale, none) +WEBDAV=none + +# Antivirus solution (value: clamav, none) +ANTIVIRUS=none + +################################### +# Mail settings +################################### + +# Message size limit in bytes +# Default: accept messages up to 50MB +MESSAGE_SIZE_LIMIT=50000000 + +# Networks granted relay permissions, make sure that you include your Docker +# internal network (default to 172.17.0.0/16) +RELAYNETS=172.16.0.0/12 + +# Will relay all outgoing mails if configured +RELAYHOST= + +# Fetchmail delay +FETCHMAIL_DELAY=600 + +# Recipient delimiter, character used to delimiter localpart from custom address part +# e.g. localpart+custom@domain;tld +RECIPIENT_DELIMITER=+ + +# DMARC rua and ruf email +DMARC_RUA=admin +DMARC_RUF=admin + +# Welcome email, enable and set a topic and body if you wish to send welcome +# emails to all users. +WELCOME=false +WELCOME_SUBJECT=Welcome to your new email account +WELCOME_BODY=Welcome to your new email account, if you can read this, then it is configured properly! + +# Maildir Compression +# choose compression-method, default: none (value: bz2, gz) +COMPRESSION= +# change compression-level, default: 6 (value: 1-9) +COMPRESSION_LEVEL= + +################################### +# Web settings +################################### + +# Path to the admin interface if enabled +WEB_ADMIN=/admin + +# Path to the webmail if enabled +WEB_WEBMAIL=/webmail + +# Website name +SITENAME=Mailu + +# Linked Website URL +WEBSITE=https://mailu.io + +# Registration reCaptcha settings (warning, this has some privacy impact) +# RECAPTCHA_PUBLIC_KEY= +# RECAPTCHA_PRIVATE_KEY= + +# Domain registration, uncomment to enable +# DOMAIN_REGISTRATION=true + +################################### +# Advanced settings +################################### + +# Docker-compose project name, this will prepended to containers names. +COMPOSE_PROJECT_NAME=mailu + +# Default password scheme used for newly created accounts and changed passwords +# (value: SHA512-CRYPT, SHA256-CRYPT, MD5-CRYPT, CRYPT) +PASSWORD_SCHEME=SHA512-CRYPT + +# Header to take the real ip from +REAL_IP_HEADER= + +# IPs for nginx set_real_ip_from (CIDR list separated by commas) +REAL_IP_FROM= From ebe90fc44704be34d5a40c6a87e0e5a7c70e5a6d Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Thu, 4 Oct 2018 14:42:34 +0300 Subject: [PATCH 03/28] Added run script for travis --- .travis.yml | 4 +++- tests/compose/core.env | 2 +- tests/compose/run.yml | 38 ++++++++++++++++++------------------ tests/compose/test-script.sh | 5 +++++ 4 files changed, 28 insertions(+), 21 deletions(-) create mode 100755 tests/compose/test-script.sh diff --git a/.travis.yml b/.travis.yml index d5114c0d..f1d36f3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,6 @@ env: - VERSION=$TRAVIS_BRANCH script: -- docker-compose -f tests/build.yml -p Mailu build + - docker-compose -f tests/build.yml -p Mailu build + - tests/compose/test-script.sh + diff --git a/tests/compose/core.env b/tests/compose/core.env index 9477448a..c92c977b 100644 --- a/tests/compose/core.env +++ b/tests/compose/core.env @@ -12,7 +12,7 @@ ROOT=/mailu # Mailu version to run (1.0, 1.1, etc. or master) -VERSION=master +#VERSION=master # Set to a randomly generated 16 bytes string SECRET_KEY=ChangeMeChangeMe diff --git a/tests/compose/run.yml b/tests/compose/run.yml index c1667db3..ceee3a3a 100644 --- a/tests/compose/run.yml +++ b/tests/compose/run.yml @@ -4,8 +4,8 @@ services: front: image: mailu/nginx:$VERSION - restart: no - env_file: $ENV_FILE + restart: 'no' + env_file: $PWD/.env ports: - "$BIND_ADDRESS4:80:80" - "$BIND_ADDRESS4:443:443" @@ -30,14 +30,14 @@ services: redis: image: redis:alpine - restart: no + restart: 'no' volumes: - "$ROOT/redis:/data" imap: image: mailu/dovecot:$VERSION - restart: no - env_file: $ENV_FILE + restart: 'no' + env_file: $PWD/.env volumes: - "$ROOT/data:/data" - "$ROOT/mail:/mail" @@ -47,8 +47,8 @@ services: smtp: image: mailu/postfix:$VERSION - restart: no - env_file: $ENV_FILE + restart: 'no' + env_file: $PWD/.env volumes: - "$ROOT/data:/data" - "$ROOT/overrides:/overrides" @@ -57,8 +57,8 @@ services: antispam: image: mailu/rspamd:$VERSION - restart: no - env_file: $ENV_FILE + restart: 'no' + env_file: $PWD/.env volumes: - "$ROOT/filter:/var/lib/rspamd" - "$ROOT/dkim:/dkim" @@ -68,22 +68,22 @@ services: antivirus: image: mailu/$ANTIVIRUS:$VERSION - restart: no - env_file: $ENV_FILE + restart: 'no' + env_file: $PWD/.env volumes: - "$ROOT/filter:/data" webdav: image: mailu/$WEBDAV:$VERSION - restart: no - env_file: $ENV_FILE + restart: 'no' + env_file: $PWD/.env volumes: - "$ROOT/dav:/data" admin: image: mailu/admin:$VERSION - restart: no - env_file: $ENV_FILE + restart: 'no' + env_file: $PWD/.env volumes: - "$ROOT/data:/data" - "$ROOT/dkim:/dkim" @@ -93,8 +93,8 @@ services: webmail: image: "mailu/$WEBMAIL:$VERSION" - restart: no - env_file: $ENV_FILE + restart: 'no' + env_file: $PWD/.env volumes: - "$ROOT/webmail:/data" depends_on: @@ -102,7 +102,7 @@ services: fetchmail: image: mailu/fetchmail:$VERSION - restart: no - env_file: $ENV_FILE + restart: 'no' + env_file: $PWD/.env volumes: - "$ROOT/data:/data" diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh new file mode 100755 index 00000000..2f33f12f --- /dev/null +++ b/tests/compose/test-script.sh @@ -0,0 +1,5 @@ +#!/bin/bash +for file in ../*.env ; do + cp $file .env + docker-compose -f ../run.yml up -d +done From 28ebcd500775124a64aecdb4397cd371f470abaf Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Thu, 4 Oct 2018 15:19:40 +0300 Subject: [PATCH 04/28] Fixed paths to files --- tests/compose/test-script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 2f33f12f..35dba8c3 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -1,5 +1,5 @@ #!/bin/bash -for file in ../*.env ; do +for file in tests/compose/*.env ; do cp $file .env - docker-compose -f ../run.yml up -d + docker-compose -f tests/compose/run.yml up -d done From 645a7f3c96cbc2be5f8ba36dbcdd79b8dce2df21 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Thu, 4 Oct 2018 15:41:44 +0300 Subject: [PATCH 05/28] Removed BIND_ADDRESS6 --- tests/compose/core.env | 2 +- tests/compose/run.yml | 9 --------- tests/compose/test-script.sh | 1 + 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/compose/core.env b/tests/compose/core.env index c92c977b..67b746f8 100644 --- a/tests/compose/core.env +++ b/tests/compose/core.env @@ -19,7 +19,7 @@ SECRET_KEY=ChangeMeChangeMe # Address where listening ports should bind BIND_ADDRESS4=127.0.0.1 -BIND_ADDRESS6=::1 +#BIND_ADDRESS6=::1 # Main mail domain DOMAIN=mailu.io diff --git a/tests/compose/run.yml b/tests/compose/run.yml index ceee3a3a..631aaa83 100644 --- a/tests/compose/run.yml +++ b/tests/compose/run.yml @@ -16,15 +16,6 @@ services: - "$BIND_ADDRESS4:25:25" - "$BIND_ADDRESS4:465:465" - "$BIND_ADDRESS4:587:587" - - "$BIND_ADDRESS6:80:80" - - "$BIND_ADDRESS6:443:443" - - "$BIND_ADDRESS6:110:110" - - "$BIND_ADDRESS6:143:143" - - "$BIND_ADDRESS6:993:993" - - "$BIND_ADDRESS6:995:995" - - "$BIND_ADDRESS6:25:25" - - "$BIND_ADDRESS6:465:465" - - "$BIND_ADDRESS6:587:587" volumes: - "$ROOT/certs:/certs" diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 35dba8c3..a0bb3c3b 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -3,3 +3,4 @@ for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml up -d done +sleep 2m From bc70be35c22007aadf72d3f6c3ddca71e2665993 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Thu, 4 Oct 2018 17:18:48 +0300 Subject: [PATCH 06/28] Added function to check docker containers --- tests/compose/test-script.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index a0bb3c3b..ffc36373 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -1,6 +1,14 @@ #!/bin/bash +containers_check() { + for container in mailu_webmail_1 mailu_imap_1 mailu_smtp_1 mailu_antispam_1 mailu_admin_1 mailu_redis_1 mailu_antivirus_1 mailu_webdav_1 mailu_fetchmail_1 mailu_front_1; do + docker inspect $container | grep '"Status": "running"' || exit 1 + done +} + for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml up -d + sleep 1m + containers_check done -sleep 2m + From 027b8f36dfb5a2a8b0a479324af7a00294a85e11 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Thu, 4 Oct 2018 17:37:09 +0300 Subject: [PATCH 07/28] Added a check for container status --- tests/compose/test-script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index ffc36373..27d78585 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -1,7 +1,8 @@ #!/bin/bash containers_check() { for container in mailu_webmail_1 mailu_imap_1 mailu_smtp_1 mailu_antispam_1 mailu_admin_1 mailu_redis_1 mailu_antivirus_1 mailu_webdav_1 mailu_fetchmail_1 mailu_front_1; do - docker inspect $container | grep '"Status": "running"' || exit 1 + echo "Checking $container" + docker inspect $container | grep '"Status": "running"' || exit 1 done } From 71eed72e212689e28a4dd366aba4df5b15219fe1 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Thu, 4 Oct 2018 17:51:17 +0300 Subject: [PATCH 08/28] Changed exit condition --- tests/compose/test-script.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 27d78585..47b1fc8c 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -1,15 +1,17 @@ #!/bin/bash containers_check() { + STATUS=0 for container in mailu_webmail_1 mailu_imap_1 mailu_smtp_1 mailu_antispam_1 mailu_admin_1 mailu_redis_1 mailu_antivirus_1 mailu_webdav_1 mailu_fetchmail_1 mailu_front_1; do echo "Checking $container" - docker inspect $container | grep '"Status": "running"' || exit 1 + docker inspect $container | grep '"Status": "running"' || STATUS=1 done + return $STATUS } for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml up -d sleep 1m - containers_check + containers_check || exit 1 done From 20f37607bbbcec0a61d1f1d7938a3f3cbb8e5ae6 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Fri, 5 Oct 2018 11:55:01 +0300 Subject: [PATCH 09/28] Added docker ps and logs --- tests/compose/test-script.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 47b1fc8c..711fd985 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -1,17 +1,39 @@ #!/bin/bash +containers=( + mailu_webmail_1 + mailu_imap_1 + mailu_smtp_1 + mailu_antispam_1 + mailu_admin_1 + mailu_redis_1 + mailu_antivirus_1 + mailu_webdav_1 +# mailu_fetchmail_1 + mailu_front_1 +) + containers_check() { STATUS=0 - for container in mailu_webmail_1 mailu_imap_1 mailu_smtp_1 mailu_antispam_1 mailu_admin_1 mailu_redis_1 mailu_antivirus_1 mailu_webdav_1 mailu_fetchmail_1 mailu_front_1; do + for container in "${containers[@]}"; do echo "Checking $container" docker inspect $container | grep '"Status": "running"' || STATUS=1 done return $STATUS } +container_logs() { + for container in "${containers[@]}"; do + echo "Showing logs for $container" + docker container logs $container + done +} + for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml up -d sleep 1m + docker ps + container_logs containers_check || exit 1 done From 59877036318607a1a7c9ae1c52719d7358078174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Fri, 5 Oct 2018 11:51:35 +0300 Subject: [PATCH 10/28] Tavis-ci to upload images to the Docker hub, after succesfull tests. For this to work, the following variables will need to be set at Docker hub: - DOCKER_ORG first part of docker repo name (example: mailu) - DOCKER_UN Docker-hub login username (private) - DOCKER_PW Docker-hub login password (private) Note that also Docker hub autobuilds will have to be disabled. --- .travis.yml | 4 ++++ tests/build.yml | 22 +++++++++++----------- tests/deploy.sh | 4 ++++ 3 files changed, 19 insertions(+), 11 deletions(-) create mode 100755 tests/deploy.sh diff --git a/.travis.yml b/.travis.yml index f1d36f3f..9fc1d02f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,3 +11,7 @@ script: - docker-compose -f tests/build.yml -p Mailu build - tests/compose/test-script.sh +deploy: + provider: script + script: bash tests/deploy.sh + diff --git a/tests/build.yml b/tests/build.yml index 674abf8c..a195fdf7 100644 --- a/tests/build.yml +++ b/tests/build.yml @@ -3,45 +3,45 @@ version: '3' services: front: - image: mailu/nginx:$VERSION + image: $DOCKER_ORG/nginx:$VERSION build: ../core/nginx imap: - image: mailu/dovecot:$VERSION + image: $DOCKER_ORG/dovecot:$VERSION build: ../core/dovecot smtp: - image: mailu/postfix:$VERSION + image: $DOCKER_ORG/postfix:$VERSION build: ../core/postfix antispam: - image: mailu/rspamd:$VERSION + image: $DOCKER_ORG/rspamd:$VERSION build: ../services/rspamd antivirus: - image: mailu/clamav:$VERSION + image: $DOCKER_ORG/clamav:$VERSION build: ../optional/clamav webdav: - image: mailu/radicale:$VERSION + image: $DOCKER_ORG/radicale:$VERSION build: ../optional/radicale admin: - image: mailu/admin:$VERSION + image: $DOCKER_ORG/admin:$VERSION build: ../core/admin roundcube: - image: mailu/roundcube:$VERSION + image: $DOCKER_ORG/roundcube:$VERSION build: ../webmails/roundcube rainloop: - image: mailu/rainloop:$VERSION + image: $DOCKER_ORG/rainloop:$VERSION build: ../webmails/rainloop fetchmail: - image: mailu/fetchmail:$VERSION + image: $DOCKER_ORG/fetchmail:$VERSION build: ../services/fetchmail none: - image: mailu/none:$VERSION + image: $DOCKER_ORG/none:$VERSION build: ../core/none diff --git a/tests/deploy.sh b/tests/deploy.sh new file mode 100755 index 00000000..0526a217 --- /dev/null +++ b/tests/deploy.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker login -u $DOCKER_UN -p $DOCKER_PW +docker-compose -f tests/build.yml push From 3224a8ecad8a5e2af50ab77c513af4040003f08b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Fri, 5 Oct 2018 12:52:19 +0300 Subject: [PATCH 11/28] Further introduction of the DOCKER_ORG variable --- tests/compose/core.env | 2 +- tests/compose/run.yml | 18 +++++++++--------- tests/compose/test-script.sh | 30 +++++++++++++++--------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/compose/core.env b/tests/compose/core.env index 67b746f8..89120d4f 100644 --- a/tests/compose/core.env +++ b/tests/compose/core.env @@ -121,7 +121,7 @@ WEBSITE=https://mailu.io ################################### # Docker-compose project name, this will prepended to containers names. -COMPOSE_PROJECT_NAME=mailu +#COMPOSE_PROJECT_NAME=mailu # Default password scheme used for newly created accounts and changed passwords # (value: SHA512-CRYPT, SHA256-CRYPT, MD5-CRYPT, CRYPT) diff --git a/tests/compose/run.yml b/tests/compose/run.yml index 631aaa83..56ea1627 100644 --- a/tests/compose/run.yml +++ b/tests/compose/run.yml @@ -3,7 +3,7 @@ version: '2' services: front: - image: mailu/nginx:$VERSION + image: $DOCKER_ORG/nginx:$VERSION restart: 'no' env_file: $PWD/.env ports: @@ -26,7 +26,7 @@ services: - "$ROOT/redis:/data" imap: - image: mailu/dovecot:$VERSION + image: $DOCKER_ORG/dovecot:$VERSION restart: 'no' env_file: $PWD/.env volumes: @@ -37,7 +37,7 @@ services: - front smtp: - image: mailu/postfix:$VERSION + image: $DOCKER_ORG/postfix:$VERSION restart: 'no' env_file: $PWD/.env volumes: @@ -47,7 +47,7 @@ services: - front antispam: - image: mailu/rspamd:$VERSION + image: $DOCKER_ORG/rspamd:$VERSION restart: 'no' env_file: $PWD/.env volumes: @@ -58,21 +58,21 @@ services: - front antivirus: - image: mailu/$ANTIVIRUS:$VERSION + image: $DOCKER_ORG/$ANTIVIRUS:$VERSION restart: 'no' env_file: $PWD/.env volumes: - "$ROOT/filter:/data" webdav: - image: mailu/$WEBDAV:$VERSION + image: $DOCKER_ORG/$WEBDAV:$VERSION restart: 'no' env_file: $PWD/.env volumes: - "$ROOT/dav:/data" admin: - image: mailu/admin:$VERSION + image: $DOCKER_ORG/admin:$VERSION restart: 'no' env_file: $PWD/.env volumes: @@ -83,7 +83,7 @@ services: - redis webmail: - image: "mailu/$WEBMAIL:$VERSION" + image: "$DOCKER_ORG/$WEBMAIL:$VERSION" restart: 'no' env_file: $PWD/.env volumes: @@ -92,7 +92,7 @@ services: - imap fetchmail: - image: mailu/fetchmail:$VERSION + image: $DOCKER_ORG/fetchmail:$VERSION restart: 'no' env_file: $PWD/.env volumes: diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 711fd985..d7d5b23c 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -1,36 +1,36 @@ #!/bin/bash containers=( - mailu_webmail_1 - mailu_imap_1 - mailu_smtp_1 - mailu_antispam_1 - mailu_admin_1 - mailu_redis_1 - mailu_antivirus_1 - mailu_webdav_1 -# mailu_fetchmail_1 - mailu_front_1 + webmail_1 + imap_1 + smtp_1 + antispam_1 + admin_1 + redis_1 + antivirus_1 + webdav_1 +# fetchmail_1 + front_1 ) containers_check() { STATUS=0 for container in "${containers[@]}"; do - echo "Checking $container" - docker inspect $container | grep '"Status": "running"' || STATUS=1 + echo "Checking ${DOCKER_ORG}_${container}" + docker inspect "${DOCKER_ORG}_${container}" | grep '"Status": "running"' || STATUS=1 done return $STATUS } container_logs() { for container in "${containers[@]}"; do - echo "Showing logs for $container" - docker container logs $container + echo "Showing logs for ${DOCKER_ORG}_${container}" + docker container logs "${DOCKER_ORG}_${container}" done } for file in tests/compose/*.env ; do cp $file .env - docker-compose -f tests/compose/run.yml up -d + docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d sleep 1m docker ps container_logs From 0c73be7c6e00ad8561642cff156f3d1157bd1513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Fri, 5 Oct 2018 13:02:10 +0300 Subject: [PATCH 12/28] Deploy on all branches --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9fc1d02f..2baa1183 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,4 +14,6 @@ script: deploy: provider: script script: bash tests/deploy.sh + on: + all_branches: true From 38db35f1d6a52ab6e7a0551b73a6722e42bc37e0 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Fri, 5 Oct 2018 15:04:04 +0300 Subject: [PATCH 13/28] Make docker ps more verbose --- tests/compose/test-script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index d7d5b23c..05285c2c 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -8,7 +8,7 @@ containers=( redis_1 antivirus_1 webdav_1 -# fetchmail_1 + fetchmail_1 front_1 ) @@ -32,7 +32,7 @@ for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d sleep 1m - docker ps + docker ps -a container_logs containers_check || exit 1 done From 4133bab280ac08d7285bf57d076cce28bb8bf404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 15:52:39 +0300 Subject: [PATCH 14/28] Default to mailu for DOCKER_ORG --- tests/compose/test-script.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 05285c2c..8b049cd6 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -12,6 +12,11 @@ containers=( front_1 ) +# Default to mailu for DOCKER_ORG +if [ -z "$DOCKER_ORG" ]; then + export DOCKER_ORG="mailu" +fi + containers_check() { STATUS=0 for container in "${containers[@]}"; do From 42f557ff382a2750752adfd9abd1610cff68ad0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 16:03:07 +0300 Subject: [PATCH 15/28] Cleanup containers --- tests/compose/test-script.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 8b049cd6..5fdddf04 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -33,12 +33,24 @@ container_logs() { done } +clean() { + docker-compose -f tests/compose/run.yml -p $DOCKER_ORG down || exit 1 + rm -fv .env +} + +# Cleanup before callig exit +die() { + clean + exit $1 +} + for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d sleep 1m docker ps -a container_logs - containers_check || exit 1 + containers_check || die 1 + clean done From 59eb4a5a00fbb4c283d244de4fef448152fc2380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 16:12:05 +0300 Subject: [PATCH 16/28] Minor script flow restructure --- tests/compose/test-script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 5fdddf04..7e3ab266 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -18,11 +18,13 @@ if [ -z "$DOCKER_ORG" ]; then fi containers_check() { + sleep 1m STATUS=0 for container in "${containers[@]}"; do echo "Checking ${DOCKER_ORG}_${container}" docker inspect "${DOCKER_ORG}_${container}" | grep '"Status": "running"' || STATUS=1 done + docker ps -a return $STATUS } @@ -47,8 +49,6 @@ die() { for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d - sleep 1m - docker ps -a container_logs containers_check || die 1 clean From 508796eaabcf1934c3dca3c7c5d2f56504b45228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 16:25:12 +0300 Subject: [PATCH 17/28] Verbose sleep --- tests/compose/test-script.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 7e3ab266..f287b4a0 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -17,8 +17,19 @@ if [ -z "$DOCKER_ORG" ]; then export DOCKER_ORG="mailu" fi +# Verbose sleep, to prevent Travis to cancel the build +# First argument is desired sleep time in minutes +v_sleep() { + COUNT=$1 + until [ $COUNT -eq 0 ]; do + echo "Sleep for $COUNT more minutes" + sleep 1m + ((COUNT--)) + done; +} + containers_check() { - sleep 1m + v_sleep 1 STATUS=0 for container in "${containers[@]}"; do echo "Checking ${DOCKER_ORG}_${container}" From 39c159bae9d74b5e56051c8e63e5f5d00bbc4064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 16:34:57 +0300 Subject: [PATCH 18/28] Make the code a bit more DRY. Put sleep back into main loop --- tests/compose/test-script.sh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index f287b4a0..4ad8ad28 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -1,15 +1,15 @@ #!/bin/bash containers=( - webmail_1 - imap_1 - smtp_1 - antispam_1 - admin_1 - redis_1 - antivirus_1 - webdav_1 - fetchmail_1 - front_1 + webmail + imap + smtp + antispam + admin + redis + antivirus + webdav + fetchmail + front ) # Default to mailu for DOCKER_ORG @@ -29,20 +29,21 @@ v_sleep() { } containers_check() { - v_sleep 1 - STATUS=0 + status=0 for container in "${containers[@]}"; do - echo "Checking ${DOCKER_ORG}_${container}" - docker inspect "${DOCKER_ORG}_${container}" | grep '"Status": "running"' || STATUS=1 + name="${DOCKER_ORG}_${container}_1" + echo "Checking $name" + docker inspect "$name" | grep '"Status": "running"' || status=1 done docker ps -a - return $STATUS + return $status } container_logs() { for container in "${containers[@]}"; do - echo "Showing logs for ${DOCKER_ORG}_${container}" - docker container logs "${DOCKER_ORG}_${container}" + name="${DOCKER_ORG}_${container}_1" + echo "Showing logs for $name" + docker container logs "$name" done } @@ -60,6 +61,7 @@ die() { for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d + v_sleep 1 container_logs containers_check || die 1 clean From bc85dff27e349749d763579d0781cc9b3792830b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 16:43:04 +0300 Subject: [PATCH 19/28] Don't try deploy is DOCKER_UN is not set --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2baa1183..66c8f405 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,4 +16,5 @@ deploy: script: bash tests/deploy.sh on: all_branches: true + condition: -z $DOCKER_UN From bb6b984610bc3ab8956a3728d7e83e42e6121a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 16:46:01 +0300 Subject: [PATCH 20/28] Exclude fetchmail for the time being. See Mailu/Mailu#412 --- tests/compose/test-script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 4ad8ad28..59b8c8a4 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -8,7 +8,7 @@ containers=( redis antivirus webdav - fetchmail +# fetchmail front ) From 7915f2631fdbf46f1fc8ec0d141ea9955aaf1d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 17:04:14 +0300 Subject: [PATCH 21/28] DOCKER_UN needs to be non-zero for deploy --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 66c8f405..1b07da5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,5 +16,5 @@ deploy: script: bash tests/deploy.sh on: all_branches: true - condition: -z $DOCKER_UN + condition: -n $DOCKER_UN From a19e11d5524b395e059724f6f816ecf025458d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 17:06:23 +0300 Subject: [PATCH 22/28] Clean terminal distortion from docker-compose in travis --- tests/compose/test-script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 59b8c8a4..30240bd0 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -61,6 +61,7 @@ die() { for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d + echo "\n" # Clean terminal distortion from docker-compose in travis v_sleep 1 container_logs containers_check || die 1 From f7d8f20c87ff1b412bcbebf359da31e229ddad80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 17:24:42 +0300 Subject: [PATCH 23/28] Move DOCKER_ORG default to travis.yml --- .travis.yml | 2 ++ tests/compose/test-script.sh | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b07da5f..a8fe1709 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,8 @@ env: - VERSION=$TRAVIS_BRANCH script: + # Default to mailu for DOCKER_ORG + - if [ -z "$DOCKER_ORG" ]; then; export DOCKER_ORG="mailu"; fi - docker-compose -f tests/build.yml -p Mailu build - tests/compose/test-script.sh diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index 30240bd0..a1ae2cf4 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -12,11 +12,6 @@ containers=( front ) -# Default to mailu for DOCKER_ORG -if [ -z "$DOCKER_ORG" ]; then - export DOCKER_ORG="mailu" -fi - # Verbose sleep, to prevent Travis to cancel the build # First argument is desired sleep time in minutes v_sleep() { From 940b88a641c70e5d849e66215aa9c73883f9a3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 17:31:01 +0300 Subject: [PATCH 24/28] Fix syntax error --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a8fe1709..8dbc2206 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: script: # Default to mailu for DOCKER_ORG - - if [ -z "$DOCKER_ORG" ]; then; export DOCKER_ORG="mailu"; fi + - if [ -z "$DOCKER_ORG" ]; then export DOCKER_ORG="mailu"; fi - docker-compose -f tests/build.yml -p Mailu build - tests/compose/test-script.sh From c09ac713a37f04538dc1c3911f38008307cd2aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 17:36:59 +0300 Subject: [PATCH 25/28] Project name can be ommitted in docker-compose build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8dbc2206..c3a19529 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: script: # Default to mailu for DOCKER_ORG - if [ -z "$DOCKER_ORG" ]; then export DOCKER_ORG="mailu"; fi - - docker-compose -f tests/build.yml -p Mailu build + - docker-compose -f tests/build.yml build - tests/compose/test-script.sh deploy: From 5716ca933e26c4976124f7ae593b0768b9f75d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 20:24:54 +0300 Subject: [PATCH 26/28] Fix autodeploy after merge with master --- tests/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build.yml b/tests/build.yml index 88040160..256e3f73 100644 --- a/tests/build.yml +++ b/tests/build.yml @@ -47,5 +47,5 @@ services: build: ../core/none docs: - image: mailu/docs:$VERSION + image: $DOCKER_ORG/docs:$VERSION build: ../docs From 1bbb86eab5aa60c9045b614edeec42934625c0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 6 Oct 2018 20:26:39 +0300 Subject: [PATCH 27/28] Add autobuild for 'setup' --- tests/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/build.yml b/tests/build.yml index 256e3f73..0b6858a0 100644 --- a/tests/build.yml +++ b/tests/build.yml @@ -49,3 +49,8 @@ services: docs: image: $DOCKER_ORG/docs:$VERSION build: ../docs + + setup: + image: $DOCKER_ORG/setup:$VERSION + build: ../setup + From c316c040c5bed10e8480bfb61bede0603970bb7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sun, 7 Oct 2018 14:08:45 +0300 Subject: [PATCH 28/28] Use travis_wait for sleep --- tests/compose/test-script.sh | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/compose/test-script.sh b/tests/compose/test-script.sh index a1ae2cf4..0a3c2237 100755 --- a/tests/compose/test-script.sh +++ b/tests/compose/test-script.sh @@ -12,16 +12,8 @@ containers=( front ) -# Verbose sleep, to prevent Travis to cancel the build -# First argument is desired sleep time in minutes -v_sleep() { - COUNT=$1 - until [ $COUNT -eq 0 ]; do - echo "Sleep for $COUNT more minutes" - sleep 1m - ((COUNT--)) - done; -} +# Time to sleep in minutes after starting the containers +WAIT=1 containers_check() { status=0 @@ -56,8 +48,8 @@ die() { for file in tests/compose/*.env ; do cp $file .env docker-compose -f tests/compose/run.yml -p $DOCKER_ORG up -d - echo "\n" # Clean terminal distortion from docker-compose in travis - v_sleep 1 + echo -e "\nSleeping for ${WAIT} minutes" # Clean terminal distortion from docker-compose in travis + travis_wait sleep ${WAIT}m || sleep ${WAIT}m #Fallback sleep for local run container_logs containers_check || die 1 clean