If it helps;
Dockerfile: FROM alpine:3.20
RUN apk add dovecot dovecot-pgsql dovecot-lmtpd RUN addgroup -S -g 1000 vmail && adduser -S vmail -G vmail -u 1000 -h /srv/vmail RUN rm -rf /etc/dovecot && mkdir /etc/dovecot && mkdir /etc/dovecot/conf.d
ADD dovecot.conf /etc/dovecot/dovecot.conf ADD conf.d/* /etc/dovecot/conf.d/
CMD ["/usr/sbin/dovecot", "-F"]
dovecot-sql-cm.yml: apiVersion: v1 kind: ConfigMap metadata: name: dovecot-sql namespace: email data: dovecot-sql.conf.ext: | driver = pgsql connect = host=DBHOST dbname=DBNAME user=DBUSER password=PSQLPASS default_pass_scheme = ARGON2ID iterate_query = SELECT userid AS user FROM mailboxes user_query = SELECT '/srv/vmail/%n' as home, 'maildir:/srv/vmail/%n' as mail, 1000 AS uid, 1000 AS gid FROM mailboxes WHERE userid = '%n' AND deleted_at IS NULL password_query = SELECT userid as user, password, '/srv/vmail/%n' as userdb_home, 'maildir:/srv/vmail/%n' as userdb_mail, 1000 as userdb_uid, 1000 as userdb_gid FROM mailboxes WHERE userid = '%n' AND deleted_at IS NULL
pvc.yml: apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mail-store namespace: email spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi
tls-cert.yml: apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: dovecot namespace: email spec: secretName: dovecot-le-cert dnsNames:
- imap.eajglobal.net issuerRef: name: letsencrypt kind: ClusterIssuer group: cert-manager.io
apiVersion: v1 kind: Secret metadata: name: dovecot-rest-certs namespace: email type: kubernetes.io/tls data: tls.crt: | ATRESTENCRYPTIONCERT tls.key: | ATRESTENCRYPTIONKEY
deployment.yml: apiVersion: apps/v1 kind: Deployment metadata: labels: app.kubernetes.io/name: dovecot name: dovecot namespace: email spec: revisionHistoryLimit: 1 selector: matchLabels: app.kubernetes.io/name: dovecot template: metadata: creationTimestamp: null labels: app.kubernetes.io/name: dovecot spec: imagePullSecrets: - name: glreg-dovecot volumes: - name: ssl-certs secret: secretName: dovecot-le-cert - name: rest-certs secret: secretName: dovecot-rest-certs - name: sql-config configMap: name: dovecot-sql items: - key: dovecot-sql.conf.ext path: dovecot-sql.conf.ext - name: mail-store persistentVolumeClaim: claimName: mail-store containers: - name: dovecot image: registry.gitlab.com/eajglobal/email-services/imap-server:LATESTSHAREF imagePullPolicy: IfNotPresent ports: - name: imaps containerPort: 993 protocol: TCP - name: lmtp containerPort: 24 protocol: TCP volumeMounts: - name: ssl-certs mountPath: /etc/dovecot/certs - name: rest-certs mountPath: /etc/dovecot/rest-certs - name: sql-config mountPath: /etc/dovecot/dovecot-sql.conf.ext subPath: dovecot-sql.conf.ext - name: mail-store mountPath: "/srv/vmail" dnsPolicy: ClusterFirstWithHostNet restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30
imap-svc.yml: apiVersion: v1 kind: Service metadata: name: imaps namespace: email labels: app.kubernetes.io/name: dovecot spec: selector: app.kubernetes.io/name: dovecot externalTrafficPolicy: Local externalIPs: ["195.184.0.0"] ports: - name: imaps protocol: TCP port: 993 targetPort: 993