-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (66 loc) · 3.14 KB
/
Makefile
File metadata and controls
79 lines (66 loc) · 3.14 KB
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
NAME := postfix
TAG := latest
IMAGE_NAME := panubo/$(NAME)
.PHONY: help bash run run-* build push clean test _ci_test
help:
@printf "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)\n"
bash: ## Runs a bash shell in the docker image
docker run --rm -it -e MAILNAME=mail.example.com $(IMAGE_NAME):$(TAG) bash
run: ## Runs the docker image in a test mode
$(eval ID := $(shell docker rm -f $(NAME) >/dev/null 2>&1; docker run -d --name $(NAME) --hostname mail.example.com \
-e RELAYHOST=172.17.0.2 \
-e MAILNAME=mail.example.com \
-e SIZELIMIT=20480000 \
-e LOGOUTPUT=/var/log/maillog \
-e CONFIG_RELOADER_ENABLED=true \
-e POSTFIX_EXPORTER_ENABLED=false $(IMAGE_NAME):$(TAG)))
$(eval IP := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${ID}))
@echo "Running ${ID} @ smtp://${IP}"
@docker attach ${ID}
@docker kill ${ID}
run-users: ## Runs the docker image in a test mode with SMTPD_USERS
$(eval ID := $(shell docker rm -f $(NAME) >/dev/null 2>&1; docker run -d --name $(NAME) --hostname mail.example.com \
-e MAILNAME=mail.example.com \
-e SIZELIMIT=20480000 \
-e SMTPD_USERS='user1:pass1,user2:pass2' \
-e LOGOUTPUT=/var/log/maillog \
$(IMAGE_NAME):$(TAG)))
$(eval IP := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${ID}))
@echo "Running ${ID} @ smtp://${IP}"
@docker attach ${ID}
@docker kill ${ID}
run-dkim: dkim.key ## Runs the docker image in a test mode with DKIM
$(eval ID := $(shell docker rm -f $(NAME) >/dev/null 2>&1; docker run -d --name $(NAME) --hostname mail.example.com \
-e RELAYHOST=172.17.0.2 \
-e MAILNAME=mail.example.com \
-e CONFIG_RELOADER_ENABLED=true \
-e USE_DKIM=yes -v $(shell pwd)/dkim.key:/etc/opendkim/dkim.key $(IMAGE_NAME):$(TAG)))
$(eval IP := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${ID}))
@echo "Running ${ID} @ smtp://${IP}"
@docker attach ${ID}
@docker kill ${ID}
run-all-dkim: dkim.key ## Runs the docker image in a test mode. All settings
$(eval ID := $(shell docker rm -f $(NAME) >/dev/null 2>&1; docker run -d --name $(NAME) --hostname mail.example.com \
-e RELAYHOST=172.17.0.2 \
-e MAILNAME=mail.example.com \
-e DKIM_DOMAINS=foo.example.com,bar.example.com,example.net \
-e DKIM_SELECTOR=6091aa68-f43d-47cf-a52e-bafda525d0bc \
-e USE_DKIM=yes -v $(shell pwd)/dkim.key:/etc/opendkim/dkim.key $(IMAGE_NAME):$(TAG)))
$(eval IP := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${ID}))
@echo "Running ${ID} @ smtp://${IP}"
@docker attach ${ID}
@docker kill ${ID}
build: ## Builds docker image latest
docker build --pull -t $(IMAGE_NAME):$(TAG) .
push: ## Pushes the docker image to hub.docker.com
docker push $(IMAGE_NAME):$(TAG)
clean: ## Remove built image
docker rmi $(IMAGE_NAME):$(TAG) || true
docker rmi $(IMAGE_NAME):$(TAG)-dev || true
test: clean ## Build a test image and run bats tests in docker
docker build --target development -t $(IMAGE_NAME):$(TAG)-dev .
docker run --rm -v $(shell pwd):/src -w /src $(IMAGE_NAME):$(TAG)-dev bats test/
_ci_test: test
true
dkim.key:
openssl genrsa -out dkim.key 2048