-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.tmpl.php
181 lines (167 loc) · 5.31 KB
/
Dockerfile.tmpl.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
$var = getopt('', ['version:', 'dockerfile:']);
$isAlpineImage = $var['dockerfile'] === 'alpine';
?>
# AUTOMATICALLY GENERATED
# DO NOT EDIT THIS FILE DIRECTLY, USE /Dockerfile.tmpl.php
<? if ($isAlpineImage) { ?>
# https://hub.docker.com/_/alpine
FROM alpine:3.20
<? } else { ?>
# https://hub.docker.com/_/debian
FROM debian:bookworm-slim
<? } ?>
ARG s6_overlay_ver=3.2.0.2
# Build and install OpenDMARC
<? if ($isAlpineImage) { ?>
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
ca-certificates \
<? } else { ?>
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends --no-install-suggests \
inetutils-syslogd \
ca-certificates \
<? } ?>
&& update-ca-certificates \
\
# Install OpenDMARC dependencies
<? if ($isAlpineImage) { ?>
&& apk add --no-cache \
libmilter libspf2 \
msmtp \
<? } else { ?>
&& apt-get install -y --no-install-recommends --no-install-suggests \
libmilter1.0.1 libspf2-2 \
msmtp-mta \
<? } ?>
\
# Install tools for building
<? if ($isAlpineImage) { ?>
&& apk add --no-cache --virtual .tool-deps \
autoconf automake coreutils curl g++ libtool make \
<? } else { ?>
&& toolDeps=" \
autoconf automake curl gcc g++ libc-dev libtool make \
" \
&& apt-get install -y --no-install-recommends --no-install-suggests \
$toolDeps \
<? } ?>
\
# Install OpenDMARC build dependencies
<? if ($isAlpineImage) { ?>
&& apk add --no-cache --virtual .build-deps \
libmilter-dev libspf2-dev \
<? } else { ?>
&& buildDeps=" \
libmilter-dev libspf2-dev \
" \
&& apt-get install -y --no-install-recommends --no-install-suggests \
$buildDeps \
<? } ?>
\
# Download and prepare OpenDMARC sources
&& curl -fL -o /tmp/opendmarc.tar.gz \
https://github.com/trusteddomainproject/OpenDMARC/archive/refs/tags/rel-opendmarc-1-4-2.tar.gz \
&& tar -xzf /tmp/opendmarc.tar.gz -C /tmp/ \
&& cd /tmp/OpenDMARC-* \
<? if ($isAlpineImage) { ?>
# Patch NETDB_* musl libc problem.
# Details: https://github.com/instrumentisto/docker-mailserver/issues/4
&& sed -i '1s;^;#if !defined(NETDB_INTERNAL)\n# define NETDB_INTERNAL (-1)\n#endif\n#if !defined(NETDB_SUCCESS)\n# define NETDB_SUCCESS (0)\n#endif\n\n;' \
libopendmarc/opendmarc_internal.h \
<? } ?>
\
# Build OpenDMARC from sources
&& autoreconf -v -i \
&& ./configure \
--prefix=/usr \
--sysconfdir=/etc/opendmarc \
--with-spf \
--with-spf2-lib=/usr/lib \
--with-spf2-include=/usr/include/spf2 \
# No documentation included to keep image size smaller
--docdir=/tmp/opendmarc/doc \
--infodir=/tmp/opendmarc/info \
--mandir=/tmp/opendmarc/man \
&& make \
\
# Create OpenDMARC user and group
<? if ($isAlpineImage) { ?>
&& addgroup -S -g 91 opendmarc \
&& adduser -S -u 90 -D -s /sbin/nologin \
-H -h /run/opendmarc \
-G opendmarc -g opendmarc \
opendmarc \
&& addgroup opendmarc mail \
<? } else { ?>
&& addgroup --system --gid 91 opendmarc \
&& adduser --system --uid 90 --disabled-password --shell /sbin/nologin \
--no-create-home --home /run/opendmarc \
--ingroup opendmarc --gecos opendmarc \
opendmarc \
&& adduser opendmarc mail \
<? } ?>
\
# Install OpenDMARC
&& make install \
# Prepare run directory
&& install -d -o opendmarc -g opendmarc /run/opendmarc/ \
# Preserve licenses
&& install -d /usr/share/licenses/opendmarc/ \
&& mv /tmp/opendmarc/doc/LICENSE* \
/usr/share/licenses/opendmarc/ \
# Prepare configuration directories
&& install -d /etc/opendmarc/conf.d/ \
\
# Cleanup unnecessary stuff
<? if ($isAlpineImage) { ?>
&& apk del .tool-deps .build-deps \
&& rm -rf /var/cache/apk/* \
<? } else { ?>
&& apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$toolDeps $buildDeps \
&& rm -rf /var/lib/apt/lists/* \
/etc/*/inetutils-syslogd \
<? } ?>
/tmp/*
# Install s6-overlay
<? if ($isAlpineImage) { ?>
RUN apk add --update --no-cache --virtual .tool-deps \
curl \
<? } else { ?>
RUN apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
curl xz-utils \
<? } ?>
&& curl -fL -o /tmp/s6-overlay-noarch.tar.xz \
https://github.com/just-containers/s6-overlay/releases/download/v${s6_overlay_ver}/s6-overlay-noarch.tar.xz \
&& curl -fL -o /tmp/s6-overlay-bin.tar.xz \
https://github.com/just-containers/s6-overlay/releases/download/v${s6_overlay_ver}/s6-overlay-x86_64.tar.xz \
&& tar -xf /tmp/s6-overlay-noarch.tar.xz -C / \
&& tar -xf /tmp/s6-overlay-bin.tar.xz -C / \
\
# Cleanup unnecessary stuff
<? if ($isAlpineImage) { ?>
&& apk del .tool-deps \
&& rm -rf /var/cache/apk/* \
<? } else { ?>
&& apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
curl xz-utils \
&& rm -rf /var/lib/apt/lists/* \
<? } ?>
/tmp/*
ENV S6_KEEP_ENV=1 \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
S6_CMD_WAIT_FOR_SERVICES=1 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=5000
COPY rootfs /
RUN chmod +x /etc/s6-overlay/s6-rc.d/*/run \
/etc/s6-overlay/s6-rc.d/*/*.sh
EXPOSE 8893
ENTRYPOINT ["/init"]
CMD ["opendmarc", "-f"]