-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile.tmpl.php
194 lines (180 loc) · 5.74 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
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
$var = getopt('', ['version:', 'dockerfile:']);
$isAlpineImage = $var['dockerfile'] === 'alpine';
$AlpineRepoCommit = '4322107ba395a710a041ee479c5805c97169a36b';
?>
# 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 opendkim_ver=<?= explode('-', $var['version'])[0].'-'.explode('-', $var['version'])[1]."\n"; ?>
ARG s6_overlay_ver=3.2.0.2
# Build and install OpenDKIM
<? if ($isAlpineImage) { ?>
# https://git.alpinelinux.org/cgit/aports/tree/community/opendkim/APKBUILD?h=<?= $AlpineRepoCommit."\n"; ?>
# TODO: Remove once `opendbx` Alpine package hits stable.
RUN echo "@edge-community https://dl-cdn.alpinelinux.org/alpine/edge/community" \
>> /etc/apk/repositories \
&& 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 OpenDKIM dependencies
<? if ($isAlpineImage) { ?>
&& apk add --no-cache --force \
libcrypto3 libssl3 \
libmilter \
opendbx \
opendbx-backend-mysql opendbx-backend-postgres opendbx-backend-sqlite \
# Perl and OpenSSL required for opendkim-* utilities
openssl perl \
<? } else { ?>
&& apt-get install -y --no-install-recommends --no-install-suggests \
libssl3 \
libmilter1.0.1 \
libopendbx1 \
libopendbx1-mysql libopendbx1-pgsql libopendbx1-sqlite3 \
libbsd0 \
<? } ?>
\
# Install tools for building
<? if ($isAlpineImage) { ?>
&& apk add --no-cache --virtual .tool-deps \
autoconf automake curl g++ libtool make \
<? } else { ?>
&& toolDeps=" \
autoconf automake curl g++ libtool make pkg-config \
" \
&& apt-get install -y --no-install-recommends --no-install-suggests \
$toolDeps \
<? } ?>
\
# Install OpenDKIM build dependencies
<? if ($isAlpineImage) { ?>
&& apk add --no-cache --virtual .build-deps \
openssl-dev \
libmilter-dev \
opendbx-dev \
<? } else { ?>
&& buildDeps=" \
libssl-dev \
libmilter-dev \
libopendbx1-dev \
libbsd-dev \
" \
&& apt-get install -y --no-install-recommends --no-install-suggests \
$buildDeps \
<? } ?>
\
# Download and prepare OpenDKIM sources
&& curl -fL -o /tmp/opendkim.tar.gz \
https://github.com/trusteddomainproject/OpenDKIM/archive/refs/tags/${opendkim_ver}.tar.gz \
&& tar -xzf /tmp/opendkim.tar.gz -C /tmp/ \
&& cd /tmp/OpenDKIM-* \
\
# Build OpenDKIM from sources
&& autoreconf -i \
&& ./configure \
--prefix=/usr \
--sysconfdir=/etc/opendkim \
--with-odbx \
--with-openssl \
--with-sql-backend \
# No documentation included to keep image size smaller
--docdir=/tmp/opendkim/doc \
--htmldir=/tmp/opendkim/html \
--infodir=/tmp/opendkim/info \
--mandir=/tmp/opendkim/man \
&& make \
\
# Create OpenDKIM user and group
<? if ($isAlpineImage) { ?>
&& addgroup -S -g 91 opendkim \
&& adduser -S -u 90 -D -s /sbin/nologin \
-H -h /run/opendkim \
-G opendkim -g opendkim \
opendkim \
&& addgroup opendkim mail \
<? } else { ?>
&& addgroup --system --gid 91 opendkim \
&& adduser --system --uid 90 --disabled-password --shell /sbin/nologin \
--no-create-home --home /run/opendkim \
--ingroup opendkim --gecos opendkim \
opendkim \
&& adduser opendkim mail \
<? } ?>
\
# Install OpenDKIM
&& make install \
# Prepare run directory
&& install -d -o opendkim -g opendkim /run/opendkim/ \
# Preserve licenses
&& install -d /usr/share/licenses/opendkim/ \
&& mv /tmp/opendkim/doc/LICENSE* \
/usr/share/licenses/opendkim/ \
# Prepare configuration directories
&& install -d /etc/opendkim/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 8891
ENTRYPOINT ["/init"]
CMD ["opendkim", "-f"]