Dockerize postfix
This commit is contained in:
parent
bcb40b3ac1
commit
edb2b6cd8c
10
basic.sh
10
basic.sh
@ -4,11 +4,10 @@ SOURCE_DIR=$(realpath $(dirname "${0}"))/basic
|
|||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
apk --no-cache add --virtual .useful git file htop libressl openssh-server openssh-sftp-server
|
apk --no-cache add --virtual .useful git file htop libressl openssh-server openssh-sftp-server
|
||||||
apk --no-cache add docker gettext kbd-misc postfix python2 nginx
|
apk --no-cache add docker gettext kbd-misc python2 nginx
|
||||||
|
|
||||||
# Copy profile files and settings
|
# Copy profile files and settings
|
||||||
mkdir /root/.ssh
|
mkdir -p /root/.config/htop /root/.ssh
|
||||||
mkdir -p /root/.config/htop
|
|
||||||
cp ${SOURCE_DIR}/root/.profile /root/.profile
|
cp ${SOURCE_DIR}/root/.profile /root/.profile
|
||||||
cp ${SOURCE_DIR}/root/.ssh/authorized_keys /root/.ssh/authorized_keys
|
cp ${SOURCE_DIR}/root/.ssh/authorized_keys /root/.ssh/authorized_keys
|
||||||
cp ${SOURCE_DIR}/root/.config/htop/htoprc /root/.config/htop/htoprc
|
cp ${SOURCE_DIR}/root/.config/htop/htoprc /root/.config/htop/htoprc
|
||||||
@ -27,9 +26,6 @@ cp ${SOURCE_DIR}/etc/issue.template /etc/issue.template
|
|||||||
cp ${SOURCE_DIR}/sbin/issue-gen /sbin/issue-gen
|
cp ${SOURCE_DIR}/sbin/issue-gen /sbin/issue-gen
|
||||||
>/etc/motd
|
>/etc/motd
|
||||||
|
|
||||||
# Configure Postfix
|
|
||||||
cp ${SOURCE_DIR}/etc/postfix/main.cf /etc/postfix/main.cf
|
|
||||||
|
|
||||||
# Create a self-signed certificate
|
# Create a self-signed certificate
|
||||||
mkdir /etc/ssl/private
|
mkdir /etc/ssl/private
|
||||||
openssl req -x509 -new -out /etc/ssl/certs/services.pem -keyout /etc/ssl/private/services.key -nodes -days 3654 -subj "/C=CZ/CN=$(hostname -f)"
|
openssl req -x509 -new -out /etc/ssl/certs/services.pem -keyout /etc/ssl/private/services.key -nodes -days 3654 -subj "/C=CZ/CN=$(hostname -f)"
|
||||||
@ -45,7 +41,7 @@ cp ${SOURCE_DIR}/usr/local/bin/portal-app-manager /usr/local/bin/portal-app-mana
|
|||||||
cp -r ${SOURCE_DIR}/srv/portal /srv/portal
|
cp -r ${SOURCE_DIR}/srv/portal /srv/portal
|
||||||
|
|
||||||
# Configure services
|
# Configure services
|
||||||
for SERVICE in crond docker nginx postfix sshd; do
|
for SERVICE in crond docker nginx sshd; do
|
||||||
rc-update add ${SERVICE} boot
|
rc-update add ${SERVICE} boot
|
||||||
service ${SERVICE} start
|
service ${SERVICE} start
|
||||||
done
|
done
|
||||||
|
18
postfix.sh
Normal file
18
postfix.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
SOURCE_DIR=$(realpath $(dirname "${0}"))/postfix
|
||||||
|
# Build Docker container
|
||||||
|
docker build -t postfix ${SOURCE_DIR}
|
||||||
|
|
||||||
|
# Copy existing config files into persistent storage
|
||||||
|
mkdir -p /srv/postfix/conf /srv/postfix/data
|
||||||
|
chown -R 587:587 /srv/postfix/data
|
||||||
|
docker run --rm -v /srv/postfix/conf:/mnt/conf postfix cp -rp /etc/postfix/. /mnt/conf
|
||||||
|
|
||||||
|
# Configure postfix
|
||||||
|
cp ${SOURCE_DIR}/srv/postfix/conf/main.cf /srv/postfix/conf/main.cf
|
||||||
|
|
||||||
|
# Configure postfix service
|
||||||
|
cp ${SOURCE_DIR}/etc/init.d/postfix /etc/init.d/postfix
|
||||||
|
rc-update add postfix boot
|
||||||
|
service postfix start
|
16
postfix/Dockerfile
Normal file
16
postfix/Dockerfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
FROM alpine:3.7
|
||||||
|
MAINTAINER Disassembler <disassembler@dasm.cz>
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
# Create OS user (which will be picked up later by apk add)
|
||||||
|
addgroup -S -g 587 postfix \
|
||||||
|
&& adduser -S -u 587 -h /var/spool/postfix -s /bin/false -g postfix -G postfix postfix \
|
||||||
|
# Install Postfix
|
||||||
|
&& apk --no-cache add ca-certificates postfix s6
|
||||||
|
|
||||||
|
COPY docker/ /
|
||||||
|
|
||||||
|
VOLUME ["/var/spool/postfix"]
|
||||||
|
EXPOSE 587
|
||||||
|
|
||||||
|
CMD ["s6-svscan", "/etc/services.d"]
|
3
postfix/docker/etc/services.d/.s6-svscan/finish
Executable file
3
postfix/docker/etc/services.d/.s6-svscan/finish
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/bin/true
|
7
postfix/docker/etc/services.d/postfix/run
Executable file
7
postfix/docker/etc/services.d/postfix/run
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
/usr/sbin/postfix -c /etc/postfix start
|
||||||
|
|
||||||
|
while kill -0 $(cat /var/spool/postfix/pid/master.pid) 2>/dev/null; do
|
||||||
|
sleep 1
|
||||||
|
done
|
3
postfix/docker/etc/services.d/syslogd/run
Executable file
3
postfix/docker/etc/services.d/syslogd/run
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/execlineb -P
|
||||||
|
|
||||||
|
/sbin/syslogd -n -S -O -
|
16
postfix/etc/init.d/postfix
Executable file
16
postfix/etc/init.d/postfix
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/sbin/openrc-run
|
||||||
|
|
||||||
|
description="Postfix docker container"
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need docker net
|
||||||
|
use dns logger netmount
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
/usr/bin/docker run -d --rm --name postfix -v /srv/postfix/conf:/etc/postfix -v /srv/postfix/data:/var/spool/postfix postfix
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
/usr/bin/docker stop postfix
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
append_dot_mydomain = no
|
append_dot_mydomain = no
|
||||||
biff = no
|
biff = no
|
||||||
compatibility_level = 2
|
compatibility_level = 2
|
||||||
inet_interfaces = loopback-only
|
|
||||||
inet_protocols = ipv4
|
inet_protocols = ipv4
|
||||||
mynetworks = 127.0.0.0/8 172.17.0.0/24
|
mynetworks = 0.0.0.0/0
|
||||||
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
|
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
|
||||||
smtp_use_tls=yes
|
smtp_use_tls = yes
|
||||||
|
smtputf8_enable = no
|
Loading…
Reference in New Issue
Block a user