-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
183 lines (160 loc) · 4.42 KB
/
docker-compose.yml
File metadata and controls
183 lines (160 loc) · 4.42 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Email Server Docker Compose Configuration
# ==========================================
#
# Usage:
# 1. Copy .env.example to .env and configure your settings
# 2. Run: docker-compose up -d
# 3. Create users: docker-compose exec email create-user add user@yourdomain.com
#
# For production deployment on a VPS:
# - Update SERVER_IP in .env to your VPS public IP
# - Update MAIL_DOMAIN to your domain
# - Configure DNS records (MX, A, PTR, SPF)
# - Consider using Let's Encrypt certificates
#
version: '3.8'
services:
email:
build:
context: .
dockerfile: Dockerfile
container_name: email-server
hostname: ${MAIL_HOSTNAME:-mail.example.com}
restart: unless-stopped
# Environment configuration
environment:
# Domain settings
- MAIL_DOMAIN=${MAIL_DOMAIN:-example.com}
- MAIL_HOSTNAME=${MAIL_HOSTNAME:-mail.example.com}
- SERVER_IP=${SERVER_IP:-0.0.0.0}
# Initial admin user (created on first run)
- ADMIN_EMAIL=${ADMIN_EMAIL:-}
- ADMIN_PASSWORD=${ADMIN_PASSWORD:-}
# Server limits
- MAX_CONNECTIONS=${MAX_CONNECTIONS:-1000}
- MAX_MESSAGE_SIZE=${MAX_MESSAGE_SIZE:-26214400}
- MAX_RECIPIENTS=${MAX_RECIPIENTS:-100}
- DEFAULT_QUOTA=${DEFAULT_QUOTA:-104857600}
# SMTP settings
- SMTP_REQUIRE_AUTH=${SMTP_REQUIRE_AUTH:-true}
- SMTP_ALLOW_RELAY=${SMTP_ALLOW_RELAY:-false}
# Logging
- LOG_LEVEL=${LOG_LEVEL:-info}
# Port mappings
ports:
# SMTP
- "${SERVER_IP:-0.0.0.0}:25:25" # SMTP (MTA)
- "${SERVER_IP:-0.0.0.0}:465:465" # SMTPS (implicit TLS)
- "${SERVER_IP:-0.0.0.0}:587:587" # Submission (STARTTLS)
# POP3
- "${SERVER_IP:-0.0.0.0}:110:110" # POP3
- "${SERVER_IP:-0.0.0.0}:995:995" # POP3S (implicit TLS)
# IMAP
- "${SERVER_IP:-0.0.0.0}:143:143" # IMAP
- "${SERVER_IP:-0.0.0.0}:993:993" # IMAPS (implicit TLS)
# Persistent volumes
volumes:
# Mail storage
- mail_data:/var/mail
# User database
- db_data:/var/lib/email_server
# SSL certificates (mount your own or let container generate self-signed)
- certs:/etc/ssl/email_server
# Configuration (optional - uncomment to use custom config file)
# - ./config/server.conf:/etc/email_server/server.conf:ro
# Logs
- logs:/var/log/email_server
# Health check
healthcheck:
test: ["CMD", "nc", "-z", "localhost", "25"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
# Resource limits (adjust based on your VPS)
deploy:
resources:
limits:
cpus: '2'
memory: 1G
reservations:
cpus: '0.5'
memory: 256M
# Security options
security_opt:
- no-new-privileges:true
# Logging configuration
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Named volumes for persistence
volumes:
mail_data:
driver: local
db_data:
driver: local
certs:
driver: local
logs:
driver: local
# Webmail client
webmail:
build:
context: ./webmail
dockerfile: Dockerfile
container_name: webmail
restart: unless-stopped
environment:
- NODE_ENV=production
- JWT_SECRET=${JWT_SECRET:-change-this-in-production-to-a-random-string}
- SESSION_EXPIRY=${SESSION_EXPIRY:-86400}
# IMAP settings
- IMAP_HOST=${IMAP_HOST:-email}
- IMAP_PORT=${IMAP_PORT:-993}
- IMAP_SECURE=${IMAP_SECURE:-true}
# SMTP settings
- SMTP_HOST=${SMTP_HOST:-email}
- SMTP_PORT=${SMTP_PORT:-465}
- SMTP_SECURE=${SMTP_SECURE:-true}
ports:
- "${SERVER_IP:-0.0.0.0}:3000:3000"
depends_on:
- email
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
deploy:
resources:
limits:
cpus: '1'
memory: 512M
reservations:
cpus: '0.25'
memory: 128M
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# Named volumes for persistence
volumes:
mail_data:
driver: local
db_data:
driver: local
certs:
driver: local
logs:
driver: local
# Network configuration
networks:
default:
driver: bridge
ipam:
config:
- subnet: 172.28.0.0/16