-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate plugin with postfwd Docker image
This commit introduces Dockerfile, which pulls official postfwd Docker Image v1.37 and installs postfwd geoip anti spam plugin. Closes #14 Signed-off-by: Ondrej Vasko <[email protected]>
- Loading branch information
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
FROM postfwd/postfwd:latest | ||
|
||
LABEL maintainer="Postfwd GeoIp Spam Plugin Maintainer <[email protected]>" | ||
|
||
ENV PATH="/opt/postfwd/sbin/:${PATH}" | ||
ENV POSTFWD_ANTISPAM_MAIN_CONFIG_PATH=/etc/postfwd/anti-spam.conf | ||
ENV POSTFWD_ANTISPAM_SQL_STATEMENTS_CONFIG_PATH=/etc/postfwd/anti-spam-sql-st.conf | ||
|
||
# Install dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
libconfig-any-perl \ | ||
libconfig-tiny-perl \ | ||
libconfig-ini-perl \ | ||
libconfig-general-perl \ | ||
libdbi-perl \ | ||
libdbd-mysql-perl \ | ||
libdbd-pg-perl \ | ||
libgeo-ip-perl \ | ||
libtime-piece-perl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy binaries into PATH | ||
RUN cp /opt/postfwd/sbin/postfwd1 /opt/postfwd/sbin/postfwd2 /usr/sbin/ | ||
|
||
# Copy entrypoint script | ||
COPY docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod 750 /usr/local/bin/docker-entrypoint.sh | ||
|
||
# Install plugin | ||
COPY --chown=postfw:postfw anti-spam-sql-st.conf /etc/postfwd/anti-spam-sql-st.conf | ||
COPY --chown=postfw:postfw postfwd-anti-spam.plugin /etc/postfwd/postfwd-anti-spam.plugin | ||
RUN chmod 644 \ | ||
/etc/postfwd/postfwd-anti-spam.plugin \ | ||
/etc/postfwd/anti-spam-sql-st.conf | ||
|
||
ENTRYPOINT ["docker-entrypoint.sh", \ | ||
"--file", "/etc/postfwd/postfwd.cf", \ | ||
"--user", "postfw", "--group", "postfw", \ | ||
"--plugins", "/etc/postfwd/postfwd-anti-spam.plugin", \ | ||
"--server_socket", "tcp:0.0.0.0:10040", \ | ||
"--cache_socket=unix::/var/lib/postfwd/postfwd.cache", \ | ||
"--pidfile=/var/lib/postfwd/postfwd.pid", \ | ||
"--save_rates=/var/lib/postfwd/postfwd.rates", \ | ||
"--stdout", "--nodaemon"] | ||
|
||
EXPOSE 10040 | ||
CMD ["postfwd2", \ | ||
"--cache=60", \ | ||
"--noidlestats", \ | ||
"--summary=600"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
# If command starts with an option, prepend postfwd2 | ||
if [ "${1:0:1}" = '-' ]; then | ||
set -- postfwd2 "$@" | ||
fi | ||
|
||
# Check if help, version or manual arguments were used | ||
want_help= | ||
for arg; do | ||
case "$arg" in | ||
--help|-h|--manual|-m|--version|-V) | ||
want_help=1 | ||
break | ||
;; | ||
esac | ||
done | ||
|
||
|
||
if [ "$1" = "postfwd1" ] || [ "$1" = "postfwd2" ] && [ -z "$want_help" ]; then | ||
if [ ! -f /etc/postfwd/anti-spam.conf ]; then | ||
echo >&2 'ERROR: Anti-spam plugin configuration file /etc/postfwd/anti-spam.conf was not found. Perhaps you forgot to mount it using "-v </absolute/path/to/anti-spam.conf>:/etc/postfwd/anti-spam.conf".' | ||
exit 1 | ||
fi | ||
chmod -R 644 /etc/postfwd/* | ||
chown -R postfw:postfw /etc/postfwd | ||
fi | ||
|
||
exec "$@" |