Add postfix and dovecot dockerfiles, added dovecot deployment (in dev)

This commit is contained in:
Quentin Legot 2023-10-05 16:26:51 +02:00
parent 1b726dc515
commit 80a4ac2156
14 changed files with 196 additions and 23 deletions

View File

@ -0,0 +1,18 @@
FROM alpine:latest
RUN apk --no-cache add dovecot dovecot-lmtpd dovecot-submissiond bash
# RUN wget https://github.com/dovecot/docker/blob/main/2.3.21/dovecot.gpg
# RUN cp dovecot.gpg /etc/apt/keyrings/dovecot.gpg
# RUN wget https://github.com/dovecot/docker/blob/main/2.3.21/dovecot.list
# RUN cp dovecot.list /etc/apt/sources.list.d
COPY password_file /etc/dovecot/secrets/dovecot_password.file
COPY dovecot.conf /etc/dovecot/dovecot.conf
EXPOSE 24
EXPOSE 143
EXPOSE 993
CMD [ "dovecot", "-F" ]

View File

@ -0,0 +1,48 @@
## You should mount /etc/dovecot if you want to
## manage this file
mail_home=/srv/mail/%Lu
mail_location=sdbox:~/Mail
mail_uid=1000
mail_gid=10000
protocols = imap submission lmtp
first_valid_uid = 1000
last_valid_uid = 10000
# authentication via passwd-file, see https://doc.dovecot.org/configuration_manual/authentication/passwd_file/#authentication-passwd-file
passdb {
driver = passwd-file
args = /etc/dovecot/secrets/dovecot_password_file
}
# post-login user lookup database, see https://doc.dovecot.org/configuration_manual/authentication/user_databases_userdb/#authentication-user-database
userdb {
driver = passwd-file
args = /etc/dovecot/secrets/dovecot_password_file
default_fields = home=/home/%u
}
ssl=no
# ssl_cert=<cert.pem
# ssl_key=<key.pem
namespace {
inbox = yes
separator = /
}
service lmtp {
inet_listener {
port = 24
}
}
listen = *
log_path=/dev/stdout
info_log_path=/dev/stdout
debug_log_path=/dev/stdout
!include_try /etc/dovecot/conf.d/*.conf

View File

@ -0,0 +1,2 @@
user:{plain}password
user2:{plain}password2

View File

@ -0,0 +1,14 @@
FROM alpine:latest
RUN apk --no-cache add postfix bash openssl
COPY startup.sh /usr/bin/startup.sh
RUN chmod +x /usr/bin/startup.sh
COPY main.cf /etc/postfix/main.cf
COPY virtual /etc/postfix/virtual
EXPOSE 25
EXPOSE 465
EXPOSE 587
CMD [ "startup.sh" ]

View File

@ -0,0 +1,14 @@
# Log everything to standard out
maillog_file = /dev/stdout
# this setting has several side-effects, e.g. the domain of this mail
# server is now example.com, http://www.postfix.org/postconf.5.html#mydomain
myhostname = mail.virt.local
# disable all compatibility levels
compatibility_level = 9999
virtual_mailbox_domains = main.virt.local
virtual_mailbox_maps = lmdb:/etc/postfix/virtual
virtual_alias_maps = lmdb:/etc/postfix/virtual
virtual_transport = lmtp:dovecot.default.svc.cluster.local:24

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -ex
postmap /etc/postfix/virtual
newaliases
exec postfix start-fg

View File

@ -0,0 +1 @@
@mail.virt.local

View File

@ -1,20 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: dovecat
labels:
app: dovecat
spec:
replicas: 1
revisionHistoryLimit: 0
selector:
matchLabels:
app: dovecat
tier: imap
strategy:
type: Recreate
template:
metadata:
app: dovecat
tier: imap

View File

@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: dovecot
labels:
app: dovecot
spec:
replicas: 1
revisionHistoryLimit: 0
selector:
matchLabels:
app: dovecot
tier: imap
strategy:
type: Recreate
template:
metadata:
app: dovecat
tier: imap
spec:
containers:
- image: git.altarik.fr/quentinlegot/dovecot:latest
name: dovecot
ports:
- containerPort: 24
name: lmtp
- containerPort: 143
name: imap
- containerPort: 993
name: imaps
volumeMounts:
- name: dovecot-secrets
mountPath: "/etc/dovecot/secrets"
readOnly: true
- name: dovecot-persistent-storage
mountPath: "/home"
volumes:
- name: dovecot-persistent-storage
persistentVolumeClaim:
claimName: dovecot-pv-claim
- name: dovecot-secrets
secret:
secretName: dovecot-secrets
defaultMode: 292

View File

@ -0,0 +1,24 @@
apiVersion: v1
kind: Service
metadata:
name: dovecot
labels:
app: dovecot
spec:
ports:
- nodePort: 30024
port: 24
protocol: TCP
targetPort: 24
- nodePort: 30143
port: 143
protocol: TCP
targetPort: 143
- nodePort: 30993
port: 993
protocol: TCP
targetPort: 993
selector:
app: dovecot
tier: imap
type: LoadBalancer

View File

@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: dovecot-pv-claim
labels:
app: dovecot
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi

View File

@ -1,8 +1,8 @@
namePrefix: mail- namePrefix: mail-
resources: resources:
- dovecat-deployment.yaml - dovecot-deployment.yaml
- dovecat-svc.yaml - dovecot-svc.yaml
- dovecat-volume.yaml - dovecot-volume.yaml
- postfix-deployment.yaml - postfix-deployment.yaml
- postfix-svc.yaml - postfix-svc.yaml