|
| 1 | +FROM jrei/systemd-debian:12 AS base |
| 2 | + |
| 3 | +ENV LANG=en_US.UTF-8 |
| 4 | + |
| 5 | +RUN echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/01norecommend && \ |
| 6 | + echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/01norecommend && \ |
| 7 | + apt-get update && \ |
| 8 | + apt-get install -y \ |
| 9 | + ca-certificates && \ |
| 10 | + DEBIAN_FRONTEND=noninteractive \ |
| 11 | + TZ=Europe/London \ |
| 12 | + apt-get install -y tzdata && \ |
| 13 | + apt-get install -y locales && \ |
| 14 | + sed -i -e "s/# $LANG.*/$LANG UTF-8/" /etc/locale.gen && \ |
| 15 | + dpkg-reconfigure --frontend=noninteractive locales && \ |
| 16 | + update-locale LANG=$LANG \ |
| 17 | + && rm -rf /var/lib/apt/lists/* |
| 18 | + |
| 19 | +RUN apt-get update && \ |
| 20 | + apt-get install -y \ |
| 21 | + openssh-client \ |
| 22 | + openssh-server \ |
| 23 | + git \ |
| 24 | + python3 \ |
| 25 | + python3-venv \ |
| 26 | + python3-virtualenv \ |
| 27 | + gcc \ |
| 28 | + python3-dev \ |
| 29 | + opendkim \ |
| 30 | + opendkim-tools \ |
| 31 | + curl \ |
| 32 | + rsync \ |
| 33 | + unbound \ |
| 34 | + unbound-anchor \ |
| 35 | + dnsutils \ |
| 36 | + postfix \ |
| 37 | + acl \ |
| 38 | + nginx \ |
| 39 | + libnginx-mod-stream \ |
| 40 | + fcgiwrap \ |
| 41 | + cron \ |
| 42 | + && for pkg in core imapd lmtpd; do \ |
| 43 | + case "$pkg" in \ |
| 44 | + core) sha256="43f593332e22ac7701c62d58b575d2ca409e0f64857a2803be886c22860f5587" ;; \ |
| 45 | + imapd) sha256="8d8dc6fc00bbb6cdb25d345844f41ce2f1c53f764b79a838eb2a03103eebfa86" ;; \ |
| 46 | + lmtpd) sha256="2f69ba5e35363de50962d42cccbfe4ed8495265044e244007d7ccddad77513ab" ;; \ |
| 47 | + esac; \ |
| 48 | + url="https://download.delta.chat/dovecot/dovecot-${pkg}_2.3.21%2Bdfsg1-3_amd64.deb"; \ |
| 49 | + file="/tmp/$(basename "$url")"; \ |
| 50 | + curl -fsSL "$url" -o "$file"; \ |
| 51 | + echo "$sha256 $file" | sha256sum -c -; \ |
| 52 | + apt-get install -y "$file"; \ |
| 53 | + rm -f "$file"; \ |
| 54 | + done \ |
| 55 | + && rm -rf /var/lib/apt/lists/* |
| 56 | + |
| 57 | +RUN systemctl enable \ |
| 58 | + ssh \ |
| 59 | + fcgiwrap |
| 60 | + |
| 61 | +RUN sed -i 's/^#PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config && \ |
| 62 | + sed -i 's/^#PermitRootLogin .*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config && \ |
| 63 | + ssh-keygen -P "" -t rsa -b 2048 -f /root/.ssh/id_rsa && \ |
| 64 | + mkdir -p /root/.ssh && \ |
| 65 | + cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && \ |
| 66 | + SSH_USER_CONFIG="/root/.ssh/config" && \ |
| 67 | + echo "Host localhost" > "$SSH_USER_CONFIG" && \ |
| 68 | + echo " HostName localhost" >> "$SSH_USER_CONFIG" && \ |
| 69 | + echo " User root" >> "$SSH_USER_CONFIG" && \ |
| 70 | + echo " StrictHostKeyChecking no" >> "$SSH_USER_CONFIG" && \ |
| 71 | + echo " UserKnownHostsFile /dev/null" >> "$SSH_USER_CONFIG" |
| 72 | + ## TODO: deny access for all insteed root form 127.0.0.1 https://unix.stackexchange.com/a/406264 |
| 73 | + |
| 74 | +WORKDIR /opt/chatmail |
| 75 | + |
| 76 | +ARG SETUP_CHATMAIL_SERVICE_PATH=/lib/systemd/system/setup_chatmail.service |
| 77 | +COPY ./files/setup_chatmail.service "$SETUP_CHATMAIL_SERVICE_PATH" |
| 78 | +RUN ln -sf "$SETUP_CHATMAIL_SERVICE_PATH" "/etc/systemd/system/multi-user.target.wants/setup_chatmail.service" |
| 79 | + |
| 80 | +COPY --chmod=555 ./files/setup_chatmail_docker.sh /setup_chatmail_docker.sh |
| 81 | +COPY --chmod=555 ./files/update_ini.sh /update_ini.sh |
| 82 | +COPY --chmod=555 ./files/entrypoint.sh /entrypoint.sh |
| 83 | + |
| 84 | +## TODO: add git clone. |
| 85 | +## Problem: how correct save only required files inside container.... |
| 86 | +# RUN git clone https://github.com/chatmail/relay.git -b master . \ |
| 87 | +# && ./scripts/initenv.sh |
| 88 | + |
| 89 | +# EXPOSE 443 25 587 143 993 |
| 90 | + |
| 91 | +VOLUME ["/sys/fs/cgroup", "/home"] |
| 92 | + |
| 93 | +STOPSIGNAL SIGRTMIN+3 |
| 94 | + |
| 95 | +ENTRYPOINT ["/entrypoint.sh"] |
| 96 | + |
| 97 | +CMD [ "--default-standard-output=journal+console", \ |
| 98 | + "--default-standard-error=journal+console" ] |
| 99 | + |
| 100 | +## TODO: Add installation and configuration of chatmaild inside the Dockerfile. |
| 101 | +## This is required to ensure repeatable deployment. |
| 102 | +## In the current MVP, the chatmaild server is updated on every container restart. |
0 commit comments