Commit a50284a5 authored by nimrod's avatar nimrod
Browse files

Dovecot image.

parent 618a4ebd
Loading
Loading
Loading
Loading

dovecot/.dockerignore

0 → 100644
+4 −0
Original line number Diff line number Diff line
*
!*.sieve
!entrypoint
!patch.diff

dovecot/Dockerfile

0 → 100644
+35 −0
Original line number Diff line number Diff line
FROM buildpack-deps:buster as delete_to_trash
RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive  apt-get install -y dovecot-dev && \
    git clone https://github.com/pali/dovecot_deleted_to_trash && \
    cd dovecot_deleted_to_trash && \
    make

FROM debian:buster-slim
RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        dovecot-ldap \
        dovecot-lmtpd \
        dovecot-imapd \
        dovecot-sieve \
        patch \
        ssl-cert \
        time \
    && \
    rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/* /var/cache/apt/archives/*
COPY --from=delete_to_trash /dovecot_deleted_to_trash/lib_deleted_to_trash_plugin.so /usr/lib/dovecot/modules/
COPY --from=delete_to_trash /dovecot_deleted_to_trash/95-deleted_to_trash_plugin.conf /etc/dovecot/conf.d/
COPY --chown=root:root entrypoint /entrypoint
COPY patch.diff /root/
RUN patch --strip 0 --verbose --directory /etc/dovecot --input /root/patch.diff && \
    doveconf
COPY --chown=mail:mail *.sieve /var/lib/dovecot/sieve.d/
RUN cd /var/lib/dovecot/sieve.d/ && \
    ls *.sieve | xargs -tn1 sievec && \
    rm *.svbin
VOLUME /var/mail
VOLUME /run/dovecot
EXPOSE 993 25
ENTRYPOINT [ "/entrypoint" ]
CMD [ "dovecot", "-F" ]
HEALTHCHECK CMD doveadm service status || exit 1

dovecot/README.md

0 → 100644
+30 −0
Original line number Diff line number Diff line
# Dovecot

> Dovecot container image.

## Exposed interfaces

The containers exposes TCP ports 25 (LMTP) and 993 (IMAPS) and the `lmtp` Unix
socket in the `/run/dovecot` volume (for LTMP submission).

## Environment variables

Name | Description
--- | ---
`LDAP_URIS` | LDAP URI (eg, `ldapi:///`).
`LDAP_BASEDN` | LDAP base DN (eg, `dc=example,dc=com`).

## Persistence

The mbox files are stored at `/var/mail`.

## License

This software is licensed under the MIT license (see `LICENSE.txt`).

## Author Information

Nimrod Adar, [contact me](mailto:nimrod@shore.co.il) or visit my [website](
https://www.shore.co.il/). Patches are welcome via [`git send-email`](
http://git-scm.com/book/en/v2/Git-Commands-Email). The repository is located
at: <https://www.shore.co.il/git/>.

dovecot/before.sieve

0 → 100644
+6 −0
Original line number Diff line number Diff line
require ["fileinto", "envelope"];
if anyof (header :contains "X-Spam-Status" "Yes",
          header :contains "X-Virus-Status" "infected")
{
    fileinto "Junk";
}

dovecot/entrypoint

0 → 100755
+16 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eux

install -d -m 755 -o dovecot -g root /var/run/dovecot
install -d -m 775 -o root -g dovecot /var/mail
install -d -m 775 -o root -g dovecot /run/dovecot
time openssl dhparam -out /usr/share/dovecot/dh.pem 4096
DEBIAN_FRONTEND=noninteractive time make-ssl-cert generate-default-snakeoil --force-overwrite

# I don't know why environment variables aren't expanded and I'm too interested
# to find out.

sed -i "s@%{env:LDAP_URIS}@$LDAP_URIS@g" /etc/dovecot/dovecot-ldap.conf.ext
sed -i "s@%{env:LDAP_BASEDN}@$LDAP_BASEDN@g" /etc/dovecot/dovecot-ldap.conf.ext

eval exec "$@"
Loading