-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (70 loc) · 2.79 KB
/
Makefile
File metadata and controls
78 lines (70 loc) · 2.79 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
.PHONY: help build test test-basic test-sasl test-uppercase clean stop
# Default target
help:
@echo "Available targets:"
@echo " make build - Build the Docker image"
@echo " make test - Run all tests"
@echo " make test-basic - Test basic configuration"
@echo " make test-sasl - Test SASL authentication setup"
@echo " make test-uppercase - Test UPPERCASE environment variables"
@echo " make clean - Remove test containers"
@echo " make stop - Stop all running test containers"
# Build the image
build:
@echo "Building croneu/postfix-relayer:latest..."
@docker build -t croneu/postfix-relayer:latest .
# Run all tests
test: build test-basic test-uppercase test-sasl
@echo ""
@echo "✅ All tests completed successfully!"
# Test basic configuration
test-basic: build
@echo ""
@echo "🧪 Testing basic configuration..."
@docker run --rm -d --name postfix-test-basic \
-e POSTFIX_myhostname=relay.local \
-e POSTFIX_mydestination=localhost \
croneu/postfix-relayer:latest
@sleep 3
@echo "--- Container logs ---"
@docker logs postfix-test-basic 2>&1 | grep -E "(Config:|maillog_file|Starting Postfix|daemon started)"
@docker stop postfix-test-basic > /dev/null 2>&1
@echo "✅ Basic configuration test passed"
# Test UPPERCASE environment variables
test-uppercase: build
@echo ""
@echo "🧪 Testing UPPERCASE environment variables..."
@docker run --rm -d --name postfix-test-uppercase \
-e POSTFIX_MYHOSTNAME=uppercase.local \
-e POSTFIX_MYDESTINATION=localhost \
-e POSTFIX_MYORIGIN=example.org \
croneu/postfix-relayer:latest
@sleep 3
@echo "--- Container logs ---"
@docker logs postfix-test-uppercase 2>&1 | grep -E "(Config:|myhostname|myorigin|mydestination)" | head -6
@docker stop postfix-test-uppercase > /dev/null 2>&1
@echo "✅ UPPERCASE environment variables test passed"
# Test SASL authentication configuration
test-sasl: build
@echo ""
@echo "🧪 Testing SASL authentication setup..."
@docker run --rm -d --name postfix-test-sasl \
-e POSTFIX_myhostname=relay.local \
-e POSTFIX_RELAYHOST='[smtp.example.com]:587' \
-e SMTP_USERNAME=testuser@example.com \
-e SMTP_PASSWORD=supersecret \
croneu/postfix-relayer:latest
@sleep 5
@echo "--- Container logs ---"
@docker logs postfix-test-sasl 2>&1 | grep -E "(Enabling SASL|sasl_auth_enable|sasl_password_maps)"
@docker stop postfix-test-sasl > /dev/null 2>&1
@echo "✅ SASL authentication test passed"
# Clean up test containers
clean: stop
@echo "Cleaning up test containers..."
@-docker rm -f postfix-test-basic postfix-test-uppercase postfix-test-sasl 2>/dev/null || true
@echo "✅ Cleanup complete"
# Stop all running test containers
stop:
@echo "Stopping test containers..."
@-docker stop postfix-test-basic postfix-test-uppercase postfix-test-sasl 2>/dev/null || true