Skip to content

Commit

Permalink
Add postfix
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Jul 1, 2024
1 parent f2df68f commit dfcae50
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
25 changes: 25 additions & 0 deletions postfix/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM alpine:3.20
ENV DOCKERIZE_VERSION v0.7.0

# install packages
RUN apk add --no-cache --update postfix bash && \
apk add --no-cache --upgrade musl musl-utils && \
(rm "/tmp/"* 2>/dev/null || true) && (rm -rf /var/cache/apk/* 2>/dev/null || true)

# install dockerize
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz

# copy postfix config file template into image
COPY main.cf.tmpl /etc/postfix/main.cf.tmpl

# copy entrypoint script into an image
COPY docker-entrypoint.sh /

# postfix is listening on port 25
EXPOSE 25
STOPSIGNAL SIGKILL

CMD /docker-entrypoint.sh

7 changes: 7 additions & 0 deletions postfix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# postfix

Started with guide at https://www.iops.tech/blog/postfix-in-alpine-docker-container/

```
Rebuild count: 0
```
6 changes: 6 additions & 0 deletions postfix/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#/usr/bin/env bash

set -eou pipefail

dockerize -template /etc/postfix/main.cf.tmpl:/etc/postfix/main.cf postfix start-fg

26 changes: 26 additions & 0 deletions postfix/main.cf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
maillog_file = /dev/stdout
smtp_helo_name = {{ .Env.POSTFIX_SMTP_HELO_NAME }}
myorigin = {{ .Env.POSTFIX_MYORIGIN }}

smtpd_banner = $myhostname ESMTP
biff = no
append_dot_mydomain = no
readme_directory = no

compatibility_level = 2

smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = {{ .Env.POSTFIX_MYHOSTNAME }}
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 192.168.0.0/16 172.16.0.0/12
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4

0 comments on commit dfcae50

Please sign in to comment.