summaryrefslogtreecommitdiffstats
path: root/Dockerfile
blob: aa35a8f14e49082aba23a882d95b9cfecf136364 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
FROM debian

ARG HOSTNAME
ARG VIRTUAL_DOMAINS
ENV DEBIAN_FRONTEND=noninteractive

# Create system users with fixed, well-known UID/GIDs
RUN useradd \
    --uid 2000 \
    --shell /usr/sbin/nologin \
    --home-dir /var/mail/vhost \
    --skel /dev/null --create-home \
    vmailbox

RUN useradd \
    --uid 2001 \
    --shell /usr/sbin/nologin \
    --home-dir /var/spool/postfix \
    postfix

RUN useradd \
    --uid 2002 \
    --shell /usr/sbin/nologin \
    --home-dir /var/spool/mlmmj \
    --skel /dev/null --create-home \
    mlmmj

RUN useradd \
    --uid 2003 \
    --shell /usr/sbin/nologin \
    --home-dir /run/opendkim \
    opendkim

RUN usermod -aG opendkim postfix

# Install packages
RUN apt update \
 && apt full-upgrade --yes \
 && apt install --yes \
    dovecot-core \
    dovecot-imapd \
    mlmmj \
    opendkim \
    postfix \
    postfix-pcre \
    sudo \
 && apt clean

# Install files
COPY dovecot /etc/dovecot/
COPY opendkim /etc/
COPY postfix /etc/postfix/
COPY userconfig /etc/userconfig/

RUN find /etc/dovecot /etc/opendkim.conf /etc/postfix -type f | xargs sed -i \
    "s/ENV_HOSTNAME/${HOSTNAME}/g; s/ENV_VIRTUAL_DOMAINS/${VIRTUAL_DOMAINS}/g"

EXPOSE 25
EXPOSE 80
EXPOSE 465
EXPOSE 993
# CMD set by docker-compose.yml