forked from dbfun/docker.mailbrocker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (86 loc) · 2.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#################################
# Application workflow
#################################
SERVICES=exim spamassassin mongo dns api rabbitmq workspace
# Run all containers
.PHONY: up
up:
@docker-compose up -d ${SERVICES}
# Stop all containers
down:
@docker-compose down
restart: down up
.PHONY: rebuild
rebuild:
@docker-compose up -d --build ${SERVICES}
# Reload all services
.PHONY: reload
reload: reload-spamassassin reload-exim reload-api reload-dns
reload-spamassassin:
@docker-compose exec spamassassin sh -c 'kill -HUP `cat /var/run/spamd.pid`'
reload-exim:
@docker-compose exec exim sh -c 'kill -HUP `cat /run/exim.pid`'
reload-api:
@docker-compose exec api pm2 restart all
reload-dns:
@docker-compose exec dns unbound-control reload
#################################
# Test and debug
#################################
# Runs all tests
.PHONY: test
test: test-unit-mocha test-integration-bash
# Runs unit test
test-unit-mocha:
@docker-compose up -d ${SERVICES}
@docker-compose exec api mocha
# Runs integration test
.PHONY: test-integration-bash
test-integration-bash:
@docker-compose up workspace
@docker-compose exec workspace bash /srv/test.sh
# Runs test container for debug purposes
.PHONY: workspace
workspace:
@docker-compose exec --user=develop workspace zsh
#################################
# Utils
#################################
# Shows DKIM public key
.PHONY: exim-dkim
exim-dkim:
@docker-compose exec exim sh /srv/dkim-show-public-key.sh
# Check IP in Blacklists (make tools-blacklist IP=127.0.0.2)
.PHONY: tools-blacklist
tools-blacklist:
@docker-compose exec api node tools/blacklist.js ${IP}
# Check IP in Blacklists (make tools-blacklist IP=127.0.0.2)
.PHONY: swaks-checkdelivery
swaks-checkdelivery:
@docker-compose run workspace sh -c "/srv/checkdelivery-send.sh"
.PHONY: dns-clear-cache
dns-clear-cache:
@docker-compose exec dns sh -c "unbound-control flush_zone ."
#################################
# Stats
#################################
# Shows exim stats
.PHONY: exim-stats
exim-stats:
@echo mail queue:
@docker-compose exec exim exim -bp
@echo exiwhat:
@docker-compose exec exim exiwhat
# Shows dns stats
.PHONY: dns-stats
dns-stats:
@docker-compose exec dns sh -c 'unbound-control stats_noreset; echo; unbound-control status'
# Shows dns cache
.PHONY: dns-cache
dns-cache:
@docker-compose exec dns unbound-control dump_cache
# Shows mail count
.PHONY: mail-stats
mail-stats:
@echo Num mails:
@echo `docker-compose exec mongo mongosh mailbroker --quiet --eval 'db.mails.countDocuments({});'`