2020-09-05 14:19:12 +00:00
|
|
|
SHELL = /bin/bash
|
|
|
|
|
2016-04-21 10:15:34 +00:00
|
|
|
NAME = tvial/docker-mailserver:testing
|
2019-10-23 09:22:23 +00:00
|
|
|
VCS_REF := $(shell git rev-parse --short HEAD)
|
2020-01-12 11:09:29 +00:00
|
|
|
VCS_VERSION := $(shell git describe --tags --contains --always)
|
2015-10-18 19:02:46 +00:00
|
|
|
|
2020-09-05 14:19:12 +00:00
|
|
|
SLEEP = 15s
|
|
|
|
|
2020-09-17 23:37:24 +00:00
|
|
|
all: build backup generate-accounts generate-accounts-after-run tests clean
|
|
|
|
no-build: backup generate-accounts generate-accounts-after-run tests clean
|
|
|
|
complete_test: lint build generate-accounts generate-accounts-after-run tests
|
2016-04-13 19:43:25 +00:00
|
|
|
|
2015-10-18 19:02:46 +00:00
|
|
|
build:
|
2019-10-23 09:22:23 +00:00
|
|
|
docker build \
|
|
|
|
--build-arg VCS_REF=$(VCS_REF) \
|
|
|
|
--build-arg VCS_VERSION=$(VCS_VERSION) \
|
|
|
|
-t $(NAME) .
|
2015-10-18 19:02:46 +00:00
|
|
|
|
2018-03-21 18:55:41 +00:00
|
|
|
backup:
|
2020-09-05 14:19:12 +00:00
|
|
|
# if backup directories exist, clean hasn't been called, therefore
|
|
|
|
# we shouldn't overwrite it. It still contains the original content.
|
2020-09-24 12:54:21 +00:00
|
|
|
@ if [ ! -d config.bak ]; then cp -rp config config.bak; fi
|
|
|
|
@ if [ ! -d testconfig.bak ]; then cp -rp test/config testconfig.bak; fi
|
2018-03-21 18:55:41 +00:00
|
|
|
|
2016-04-25 14:00:39 +00:00
|
|
|
generate-accounts:
|
2020-09-05 14:19:12 +00:00
|
|
|
@ docker run --rm -e MAIL_USER=user1@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' > test/config/postfix-accounts.cf
|
|
|
|
@ docker run --rm -e MAIL_USER=user2@otherdomain.tld -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf
|
|
|
|
@ echo "# this is a test comment, please don't delete me :'(" >> test/config/postfix-accounts.cf
|
|
|
|
@ echo " # this is also a test comment, :O" >> test/config/postfix-accounts.cf
|
2016-08-21 20:13:13 +00:00
|
|
|
|
2020-09-17 22:39:32 +00:00
|
|
|
# TODO: ensure this is run per container after each container started!
|
2017-10-10 06:15:18 +00:00
|
|
|
generate-accounts-after-run:
|
2020-09-20 00:13:05 +00:00
|
|
|
# todo: noone seems to care about this?
|
|
|
|
#@ docker run --rm -e MAIL_USER=added@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf
|
2020-09-05 14:19:12 +00:00
|
|
|
@ sleep $(SLEEP)
|
2017-12-31 11:33:48 +00:00
|
|
|
|
2015-10-18 19:02:46 +00:00
|
|
|
tests:
|
2019-08-07 00:24:56 +00:00
|
|
|
./test/bats/bin/bats test/*.bats
|
|
|
|
|
|
|
|
.PHONY: ALWAYS_RUN
|
|
|
|
test/%.bats: ALWAYS_RUN
|
|
|
|
./test/bats/bin/bats $@
|
2016-01-22 17:47:43 +00:00
|
|
|
|
|
|
|
clean:
|
2020-09-05 14:19:12 +00:00
|
|
|
# remove running and stopped test containers
|
|
|
|
-@ docker ps -a | grep -E "docker-mailserver:testing|ldap_for_mail" | cut -f 1-1 -d ' ' | xargs --no-run-if-empty docker rm -f
|
|
|
|
-@ if [ -d config.bak ]; then\
|
2018-03-21 18:55:41 +00:00
|
|
|
rm -rf config ;\
|
2018-03-16 17:52:49 +00:00
|
|
|
mv config.bak config ;\
|
2016-09-12 15:49:46 +00:00
|
|
|
fi
|
2020-09-05 14:19:12 +00:00
|
|
|
-@ if [ -d testconfig.bak ]; then\
|
2018-04-02 08:45:58 +00:00
|
|
|
sudo rm -rf test/config ;\
|
2018-03-21 18:55:41 +00:00
|
|
|
mv testconfig.bak test/config ;\
|
|
|
|
fi
|
2020-09-21 23:08:28 +00:00
|
|
|
-@ sudo rm -rf test/onedir test/alias test/quota test/relay test/config/dovecot-lmtp/userdb test/config/key* test/config/opendkim/keys/domain.tld/ test/config/opendkim/keys/example.com/ test/config/opendkim/keys/localdomain2.com/ test/config/postfix-aliases.cf test/config/postfix-receive-access.cf test/config/postfix-receive-access.cfe test/config/dovecot-quotas.cf test/config/postfix-send-access.cf test/config/postfix-send-access.cfe test/config/relay-hosts/chksum test/config/relay-hosts/postfix-aliases.cf test/config/dhparams.pem test/config/dovecot-lmtp/dh.pem test/config/relay-hosts/dovecot-quotas.cf test/config/user-patches.sh test/alias/config/postfix-virtual.cf test/quota/config/dovecot-quotas.cf test/quota/config/postfix-accounts.cf test/relay/config/postfix-relaymap.cf test/relay/config/postfix-sasl-password.cf test/duplicate_configs/
|
2020-09-05 14:19:12 +00:00
|
|
|
|
2020-10-04 17:34:15 +00:00
|
|
|
lint: eclint hadolint shellcheck
|
|
|
|
|
|
|
|
hadolint:
|
|
|
|
@ ./test/linting/lint.sh hadolint
|
|
|
|
|
2020-09-05 14:19:12 +00:00
|
|
|
shellcheck:
|
2020-10-04 17:34:15 +00:00
|
|
|
@ ./test/linting/lint.sh shellcheck
|
2020-09-24 12:54:21 +00:00
|
|
|
|
|
|
|
eclint:
|
2020-10-04 17:34:15 +00:00
|
|
|
@ ./test/linting/lint.sh eclint
|