Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .devcontainer/conf/db/init-sogo-mysql.db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,24 @@ CREATE USER IF NOT EXISTS 'sogo'@'%' IDENTIFIED BY 'sogo';
GRANT ALL PRIVILEGES ON `sogo`.* TO 'sogo'@'%';

-- GRANT ALL PRIVILEGES ON *.* TO 'sogo'@'%' WITH GRANT OPTION;
-- FLUSH PRIVILEGES;
-- FLUSH PRIVILEGES;


-- Create the user source tables

USE `sogo`;

CREATE TABLE IF NOT EXISTS `sogo_users` (
`uid` VARCHAR(255) NOT NULL PRIMARY KEY,
`mail` VARCHAR(255) NOT NULL,
`password` VARCHAR(255) NOT NULL,
`cn` VARCHAR(255) NOT NULL,
`ou` VARCHAR(255) NOT NULL
);

-- Insert the three users
INSERT INTO `sogo_users` (`uid`, `mail`, `password`, `cn`, `ou`)
VALUES
('sogo-db1@example.org', 'sogo-db1@example.org', 'sogo', 'Dude db', 'example.org'),
('sogo-db2@example.org', 'sogo-db2@example.org', 'sogo', 'Hewill db', 'example.org'),
('sogo-db3@example.org', 'sogo-db3@example.org', 'sogo', 'Ithas db', 'example.org');
19 changes: 19 additions & 0 deletions .devcontainer/conf/db/init-sogo-postgres.db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,22 @@ CREATE ROLE sogo WITH
CREATE DATABASE sogo;
GRANT ALL PRIVILEGES ON DATABASE sogo TO sogo;


-- Connect to the database
\c sogo

-- Create the sogo_users table
CREATE TABLE sogo_users (
uid TEXT NOT NULL PRIMARY KEY,
mail TEXT NOT NULL,
password TEXT NOT NULL,
cn TEXT NOT NULL,
ou TEXT NOT NULL
);

-- Insert the three users
INSERT INTO sogo_users (uid, mail, password, cn, ou)
VALUES
('sogo-db1@example.org', 'sogo-db1@example.org', 'sogo', 'Dude db', 'example.org'),
('sogo-db2@example.org', 'sogo-db2@example.org', 'sogo', 'Hewill db', 'example.org'),
('sogo-db3@example.org', 'sogo-db3@example.org', 'sogo', 'Ithas db', 'example.org');
88 changes: 33 additions & 55 deletions .devcontainer/conf/dovecot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,72 +1,50 @@
# From https://github.com/dovecot/docker/blob/main/2.3.21.1/
FROM debian:11-slim
# Use Debian Trixie (13) as the base image
FROM debian:13-slim

LABEL org.opencontainers.image.authors="dovecot@dovecot.org"

ENV container=docker \
# Set environment variables to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive \
LC_ALL=C
ARG DEBIAN_FRONTEND=noninteractive

ADD dovecot.gpg /etc/apt/keyrings/dovecot.gpg
ADD dovecot.list /etc/apt/sources.list.d

RUN apt-get -y update && apt-get -y install \
tini \
dovecot-core \
dovecot-gssapi \
dovecot-imapd \
dovecot-ldap \
dovecot-lmtpd \
dovecot-managesieved \
dovecot-mysql \
dovecot-pgsql \
dovecot-pop3d \
dovecot-sieve \
dovecot-solr \
dovecot-sqlite \
dovecot-submissiond \
ca-certificates \
ssl-cert && \
rm -rf /var/lib/apt/lists && \
# Update and install Dovecot 2.4 with LDA, Sieve, LDAP, and SQL
RUN apt-get update && \
apt-get install -y --no-install-recommends \
dovecot-core \
dovecot-imapd \
dovecot-lmtpd \
dovecot-sieve \
dovecot-ldap \
dovecot-mysql \
dovecot-pgsql \
ca-certificates \
ssl-cert && \
groupadd -g 1000 vmail && \
useradd -u 1000 -g 1000 vmail -d /srv/vmail && \
passwd -l vmail && \
rm -rf /etc/dovecot && \
mkdir /srv/mail && \
chown vmail:vmail /srv/mail && \
make-ssl-cert generate-default-snakeoil && \
mkdir /etc/dovecot && \
# mkdir /var/mail && \
chown -R vmail:vmail /var/mail && \
rm -rf /var/lib/apt/lists/*

# Generate a default SSL certificate (self-signed)
RUN make-ssl-cert generate-default-snakeoil && \
mkdir -p /etc/dovecot && \
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/dovecot/cert.pem && \
ln -s /etc/ssl/private/ssl-cert-snakeoil.key /etc/dovecot/key.pem

#ADD dovecot.conf /etc/dovecot/dovecot.conf

# Add for SOGo env
RUN apt-get update --allow-insecure-repositories && \
apt-get install --allow-unauthenticated -y dovecot-ldap dovecot-sieve dovecot-managesieved dovecot-lmtpd

RUN chown -R dovecot:dovecot /var/mail
RUN mkdir /var/sieve && \
chmod -R 755 /var/sieve && \
chown -R vmail:vmail /var/sieve

# Clean
# Conf
ADD dovecot.conf /etc/dovecot/dovecot.conf
ADD conf.d /etc/dovecot/conf.d
ADD dovecot-ldap.conf.ext /etc/dovecot/dovecot-ldap.conf.ext
ADD dovecot-oauth2.conf.ext /etc/dovecot/dovecot-oauth2.conf.ext
ADD dovecot-oauth2.authentik.conf.ext /etc/dovecot/dovecot-oauth2.authentik.conf.ext
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# End add for SOGo env

EXPOSE 24
EXPOSE 110
# Expose Dovecot ports
# 143 = IMAP
# 993 = IMAPS
# 24 = LMTP
# 587 = Submission
EXPOSE 143
EXPOSE 587
EXPOSE 990
EXPOSE 993
EXPOSE 4190
EXPOSE 24
EXPOSE 587

# Start Dovecot in the foreground
VOLUME ["/etc/dovecot", "/srv/mail"]
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/usr/sbin/dovecot", "-F"]
CMD ["/usr/sbin/dovecot", "-F"]
9 changes: 6 additions & 3 deletions .devcontainer/conf/dovecot/conf.d/10-auth.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
disable_plaintext_auth = no
auth_mechanisms = plain login xoauth2
auth_allow_cleartext = yes

auth_mechanisms = plain login #xoauth2

!include auth-ldap.conf.ext
!include auth-oauth2.conf.ext
#!include auth-oauth2.conf.ext
#!include auth-sql.conf.ext
87 changes: 87 additions & 0 deletions .devcontainer/conf/dovecot/conf.d/10-logging.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
##
## Log destination.
##

# Log file to use for error messages. "syslog" logs to syslog,
# /dev/stderr logs to stderr.
log_path = /dev/stderr

# Log file to use for informational messages. Defaults to log_path.
#info_log_path =
# Log file to use for debug messages. Defaults to info_log_path.
#debug_log_path =

# Syslog facility to use if you're logging to syslog. Usually if you don't
# want to use "mail", you'll use local0..local7. Also other standard
# facilities are supported.
#syslog_facility = mail

##
## Logging verbosity and debugging.
##

# Log unsuccessful authentication attempts and the reasons why they failed.
auth_verbose = yes

# In case of password mismatches, log the attempted password. Valid values are
# no, plain and sha1. sha1 can be useful for detecting brute force password
# attempts vs. user simply trying the same password over and over again.
#auth_verbose_passwords = no

# To chain multiple logging conditions you can use,
# log_debug=$SET:log_debug or category=xxx

# Even more verbose logging for debugging purposes. Shows for example SQL
# queries.
log_debug=category=auth

#
# In case of password mismatches, log the passwords and used scheme so the
# problem can be debugged. Enabling this also enables auth_debug.
#auth_debug_passwords = yes

# Enable mail process debugging. This can help you figure out why Dovecot
# isn't finding your mails.
log_debug=category=mail

# Show protocol level SSL errors.
#log_debug=category=ssl

# mail_log plugin provides more event logging for mail processes.
mail_plugins {
notify = yes
mail_log = yes
}
# Events to log. Also available: flag_change append
#mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename flag_change append
# Available fields: uid, box, msgid, from, subject, size, vsize, flags
# size and vsize are available only for expunge and copy events.
#mail_log_fields = uid box msgid size from subject vsize flags
# only log cached fields
#mail_log_cached_only = yes

##
## Log formatting.
##

# Prefix for each line written to log file. % codes are in strftime(3)
# format.
#log_timestamp = "%b %d %H:%M:%S "

# Space-separated list of elements we want to log. The elements which have
# a non-empty variable value are joined together to form a comma-separated
# string.
#login_log_format_elements = user=<%{user}> method=%{mechanism} rip=%{remote_ip} lip=%{local_ip} mpid=%{mail_pid} %{secured} session=<%{session}>

# Login log format. %{elements} contains login_log_format_elements string, %{message} contains
# the data we want to log.
#login_log_format = %{message}: %{elements}

# Log prefix for mail processes. See
# https://doc.dovecot.org/latest/core/settings/variables.html#mail-service-user-variables
# for list of possible variables.
#mail_log_prefix = "%{service}(%{user})<%{process:pid}><%{session}>: "

# Format to use for logging mail deliveries. See https://doc.dovecot.org/latest/core/summaries/settings.html#deliver_log_format
# for list of possible variables.
#deliver_log_format = msgid=%{msgid}: %{message} (subject=%{subject} from=%{from} size=%{size})
60 changes: 32 additions & 28 deletions .devcontainer/conf/dovecot/conf.d/10-mail.conf
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
mail_location = maildir:/var/mail/%n
mail_privileged_group = vmail

mail_uid = vmail
mail_gid = vmail

mail_driver = maildir
mail_path = /var/mail/%{user | username}

namespace inbox {
inbox = yes
# prefix = INBOX.
separator = /
prefix = INBOX/
}

namespace second {
prefix = "#foo"
separator = "/"
list = no
namespace shared {
type = shared
separator = /
prefix = shared/$user/
mail_path = /var/mail/%{owner_user | username}
mail_index_private_path = /var/mail/%{user | username}/shared/%{owner_user | username}
subscriptions = no
list = children
}

mail_privileged_group = mail
protocol !indexer-worker {
mail_plugins {
acl = yes
quota = yes
}

# namespace {
# type = shared
# # separator = /
# prefix = shared/%%n/
# # a) Per-user seen flags. Maildir indexes are shared. (INDEXPVT requires v2.2+)
# location = maildir:%%h/Maildir:INDEXPVT=~/Maildir/shared/%%u
# # b) Per-user seen flags. Maildir indexes are not shared. If users have direct filesystem level access to their mails, this is a safer option:
# #location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u:INDEXPVT=~/Maildir/shared/%%u
# subscriptions = no
# list = children
# }

# Enable internal ACL support
mail_plugins = $mail_plugins acl quota

# Enable the IMAP ACL commands
protocol imap {
mail_plugins = $mail_plugins imap_acl imap_quota
mail_plugins {
imap_acl = yes
imap_quota = yes
}
}

plugin {
acl = vfile
acl_shared_dict = file:/etc/dovecot/sharing.db

acl_driver = vfile

acl_sharing_map {
dict file {
path = /etc/dovecot/sharing.db
}
}
17 changes: 3 additions & 14 deletions .devcontainer/conf/dovecot/conf.d/10-master.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@ service imap-login {
#port = 993
#ssl = yes
}
}

service pop3-login {
inet_listener pop3 {
#port = 110
}
inet_listener pop3s {
#port = 995
#ssl = yes
}
}

service submission-login {
Expand All @@ -25,7 +16,7 @@ service submission-login {
}

service lmtp {
unix_listener /var/spool/dovecot-lmtp {
unix_listener lmtp {
mode = 0660
user = root
group = root
Expand All @@ -42,12 +33,10 @@ service imap {

# Max. number of IMAP processes (connections)
#process_limit = 1024
user = vmail
group = vmail
}

service pop3 {
# Max. number of POP3 processes (connections)
#process_limit = 1024
}

service submission {
# Max. number of SMTP Submission processes (connections)
Expand Down
Loading
Loading