Initial: stack mail Postfix + Dovecot sur Alpine
This commit is contained in:
commit
24cf567d9a
5 changed files with 98 additions and 0 deletions
43
postfix/Dockerfile
Normal file
43
postfix/Dockerfile
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Image de base Alpine, légère
|
||||
FROM alpine:3.21
|
||||
|
||||
# Installer Postfix et les outils
|
||||
RUN apk add --no-cache postfix postfix-pcre rsyslog
|
||||
|
||||
# --- Utilisateur dédié au stockage des mails virtuels ---
|
||||
# Tous les mails appartiendront à cet utilisateur "vmail" (uid/gid 5000)
|
||||
# Supprimer le vmail créé par défaut par Postfix, puis recréer le nôtre en uid/gid 5000
|
||||
RUN (deluser vmail 2>/dev/null || true) \
|
||||
&& (delgroup vmail 2>/dev/null || true) \
|
||||
&& addgroup -g 5000 vmail \
|
||||
&& adduser -D -u 5000 -G vmail -h /var/mail/vhosts vmail \
|
||||
&& mkdir -p /var/mail/vhosts/ayoinc.test \
|
||||
&& chown -R vmail:vmail /var/mail/vhosts
|
||||
# --- Configuration Postfix de base ---
|
||||
RUN postconf -e "myhostname = mail.ayoinc.test" \
|
||||
&& postconf -e "mydomain = ayoinc.test" \
|
||||
&& postconf -e "myorigin = \$mydomain" \
|
||||
# Postfix ne gère PAS lui-même notre domaine en "local" : c'est du virtuel
|
||||
&& postconf -e "mydestination = localhost" \
|
||||
&& postconf -e "inet_interfaces = all" \
|
||||
&& postconf -e "inet_protocols = ipv4"
|
||||
|
||||
# --- Configuration des boîtes virtuelles ---
|
||||
RUN postconf -e "virtual_mailbox_domains = ayoinc.test" \
|
||||
&& postconf -e "virtual_mailbox_base = /var/mail/vhosts" \
|
||||
&& postconf -e "virtual_mailbox_maps = lmdb:/etc/postfix/vmailbox" \
|
||||
&& postconf -e "virtual_minimum_uid = 5000" \
|
||||
&& postconf -e "virtual_uid_maps = static:5000" \
|
||||
&& postconf -e "virtual_gid_maps = static:5000"
|
||||
|
||||
# --- Déclaration des comptes virtuels (alice & bob) ---
|
||||
# Chaque ligne : adresse -> chemin Maildir (le / final = format Maildir)
|
||||
RUN echo "alice@ayoinc.test ayoinc.test/alice/" > /etc/postfix/vmailbox \
|
||||
&& echo "bob@ayoinc.test ayoinc.test/bob/" >> /etc/postfix/vmailbox \
|
||||
&& postmap lmdb:/etc/postfix/vmailbox
|
||||
|
||||
# Exposer le port SMTP
|
||||
EXPOSE 25
|
||||
|
||||
# Lancer Postfix au premier plan
|
||||
CMD ["postfix", "start-fg"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue