-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.mda
66 lines (50 loc) · 2.05 KB
/
Dockerfile.mda
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
63
64
65
66
# Use the official Ubuntu image as a base
FROM ubuntu:latest
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
# Update the package list and install necessary packages
RUN apt-get update && \
apt install -y dovecot-core && \
apt-get install -y dovecot-pop3d dovecot-imapd
RUN apt-get clean
# Set the working directory
WORKDIR /etc/dovecot
# Copy the Dovecot configuration file
COPY dovecot.conf /etc/dovecot/dovecot.conf
# SSL Configuration
COPY ./ssl/dovecot.pem /etc/dovecot/dovecot.pem
COPY ./ssl/dovecot.pem.private /etc/dovecot/private/dovecot.pem
COPY ./ssl/dh.pem /etc/dovecot/dh.pem
RUN chmod 644 /etc/dovecot/private/dovecot.pem && \
chmod 644 /etc/dovecot/dh.pem && \
chmod 644 /etc/dovecot/dovecot.pem
RUN sed -i '/^ssl_cert/d' /etc/dovecot/conf.d/10-ssl.conf && \
sed -i '/^ssl_key/d' /etc/dovecot/conf.d/10-ssl.conf && \
sed -i '/^ssl_dh/d' /etc/dovecot/conf.d/10-ssl.conf
RUN echo "ssl = yes" >> /etc/dovecot/conf.d/10-ssl.conf && \
echo "ssl_dh = </etc/dovecot/dh.pem" >> /etc/dovecot/conf.d/10-ssl.conf && \
echo "ssl_cert = </etc/dovecot/dovecot.pem" >> /etc/dovecot/conf.d/10-ssl.conf && \
echo "ssl_key = </etc/dovecot/private/dovecot.pem" >> /etc/dovecot/conf.d/10-ssl.conf
## Delete Old SSL Parameters
RUN rm -f /var/lib/dovecot/ssl-parameters.dat
# Copy the user database file
COPY dovecot-users /etc/dovecot/dovecot-users
# Set permissions for the user database file
RUN chmod 644 /etc/dovecot/dovecot-users
# Initialize files
RUN touch /var/log/dovecot-info.log /var/log/dovecot.log /var/log/dovecot-debug.log
# Expose the POP3 and IMAP ports
EXPOSE 110 143 993 12345
## Maildir
#RUN mkdir -p /var/mail/vmail /var/vmail && \
# chmod 777 -R /var/mail /var/vmail
# Set user
ARG UNAME=vmail
ARG UID=1000
ARG GID=1000
RUN groupadd -g $GID -o $UNAME && \
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME && \
usermod -aG root vmail
USER root
# Start Dovecot service
CMD ["sh", "-c", "dovecot -F & tail -f /var/log/dovecot-info.log & tail -f /var/log/dovecot.log & tail -f /var/log/dovecot-debug.log"]