diff --git a/.travis.yml b/.travis.yml index d5114c0d..c3a19529 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,15 @@ env: - VERSION=$TRAVIS_BRANCH script: -- docker-compose -f tests/build.yml -p Mailu build + # Default to mailu for DOCKER_ORG + - if [ -z "$DOCKER_ORG" ]; then export DOCKER_ORG="mailu"; fi + - docker-compose -f tests/build.yml build + - tests/compose/test-script.sh + +deploy: + provider: script + script: bash tests/deploy.sh + on: + all_branches: true + condition: -n $DOCKER_UN + diff --git a/tests/build.yml b/tests/build.yml index c39b0af4..0b6858a0 100644 --- a/tests/build.yml +++ b/tests/build.yml @@ -3,49 +3,54 @@ 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 docs: - image: mailu/docs:$VERSION + image: $DOCKER_ORG/docs:$VERSION build: ../docs + + setup: + image: $DOCKER_ORG/setup:$VERSION + build: ../setup + diff --git a/tests/compose/core.env b/tests/compose/core.env new file mode 100644 index 00000000..89120d4f --- /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= diff --git a/tests/compose/run.yml b/tests/compose/run.yml new file mode 100644 index 00000000..56ea1627 --- /dev/null +++ b/tests/compose/run.yml @@ -0,0 +1,99 @@ +version: '2' + +services: + + front: + image: $DOCKER_ORG/nginx:$VERSION + restart: 'no' + env_file: $PWD/.env + 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" + volumes: + - "$ROOT/certs:/certs" + + redis: + image: redis:alpine + restart: 'no' + volumes: + - "$ROOT/redis:/data" + + imap: + image: $DOCKER_ORG/dovecot:$VERSION + restart: 'no' + env_file: $PWD/.env + volumes: + - "$ROOT/data:/data" + - "$ROOT/mail:/mail" + - "$ROOT/overrides:/overrides" + depends_on: + - front + + smtp: + image: $DOCKER_ORG/postfix:$VERSION + restart: 'no' + env_file: $PWD/.env + volumes: + - "$ROOT/data:/data" + - "$ROOT/overrides:/overrides" + depends_on: + - front + + antispam: + image: $DOCKER_ORG/rspamd:$VERSION + restart: 'no' + env_file: $PWD/.env + volumes: + - "$ROOT/filter:/var/lib/rspamd" + - "$ROOT/dkim:/dkim" + - "$ROOT/overrides/rspamd:/etc/rspamd/override.d" + depends_on: + - front + + antivirus: + image: $DOCKER_ORG/$ANTIVIRUS:$VERSION + restart: 'no' + env_file: $PWD/.env + volumes: + - "$ROOT/filter:/data" + + webdav: + image: $DOCKER_ORG/$WEBDAV:$VERSION + restart: 'no' + env_file: $PWD/.env + volumes: + - "$ROOT/dav:/data" + + admin: + image: $DOCKER_ORG/admin:$VERSION + restart: 'no' + env_file: $PWD/.env + volumes: + - "$ROOT/data:/data" + - "$ROOT/dkim:/dkim" + - /var/run/docker.sock:/var/run/docker.sock:ro + depends_on: + - redis + + webmail: + image: "$DOCKER_ORG/$WEBMAIL:$VERSION" + restart: 'no' + env_file: $PWD/.env + volumes: + - "$ROOT/webmail:/data" + depends_on: + - imap + + fetchmail: + image: $DOCKER_ORG/fetchmail:$VERSION + 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..0a3c2237 --- /dev/null +++ b/tests/compose/test-script.sh @@ -0,0 +1,57 @@ +#!/bin/bash +containers=( + webmail + imap + smtp + antispam + admin + redis + antivirus + webdav +# fetchmail + front +) + +# Time to sleep in minutes after starting the containers +WAIT=1 + +containers_check() { + status=0 + for container in "${containers[@]}"; do + name="${DOCKER_ORG}_${container}_1" + echo "Checking $name" + docker inspect "$name" | grep '"Status": "running"' || status=1 + done + docker ps -a + return $status +} + +container_logs() { + for container in "${containers[@]}"; do + name="${DOCKER_ORG}_${container}_1" + echo "Showing logs for $name" + docker container logs "$name" + 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 + 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 +done + 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