-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile.tmpl.php
243 lines (226 loc) · 7.18 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
$var = getopt('', ['version:', 'dockerfile:']);
$isApacheImage = explode('/', $var['dockerfile'])[1] === 'apache';
$RoundcubeVer = explode('-', $var['version'])[0];
$isMinorVerGt5 = (intval(explode('.', $RoundcubeVer)[1]) > 5);
$phpVer = '8.2';
$alpineVer = '3.21';
?>
# AUTOMATICALLY GENERATED
# DO NOT EDIT THIS FILE DIRECTLY, USE /Dockerfile.tmpl.php
# https://hub.docker.com/_/php
<? if ($isApacheImage) { ?>
FROM php:<?= $phpVer; ?>-apache
<? } else { ?>
FROM php:<?= $phpVer; ?>-fpm-alpine<?= $alpineVer."\n"; ?>
<? } ?>
ARG roundcube_ver=<?= $RoundcubeVer."\n"; ?>
ARG s6_overlay_ver=3.2.0.2
# Install s6-overlay
RUN 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 / \
&& rm -rf /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
# Install required libraries and PHP extensions
<? if ($isApacheImage) { ?>
RUN apt-get update \
&& apt-get upgrade -y \
<? } else { ?>
RUN apk update \
&& apk upgrade \
<? } ?>
&& update-ca-certificates \
<? if ($isApacheImage) { ?>
&& apt-get install -y --no-install-recommends --no-install-suggests \
inetutils-syslogd \
gnupg \
&& apt-get install -y --no-install-recommends --no-install-suggests \
libpq5 libodbc1 libsybdb5 \
libaspell15 \
libicu72 \
libldap-2.5-0 libsasl2-2 \
libjpeg62-turbo libpng16-16 libfreetype6 \
libzip4 \
<? } else { ?>
&& apk add --no-cache --virtual .plugin-deps \
gnupg \
&& apk add --no-cache --virtual .php-ext-deps \
libpq unixodbc freetds \
aspell-libs \
icu-libs \
libldap \
libjpeg-turbo libpng freetype \
libzip \
zlib \
<? } ?>
\
<? if ($isApacheImage) { ?>
&& buildDeps=" \
libpq-dev unixodbc-dev freetds-dev \
libpspell-dev \
libicu-dev \
libldap2-dev \
libjpeg62-turbo-dev libpng-dev libfreetype6-dev \
libzip-dev \
" \
&& apt-get install -y --no-install-recommends --no-install-suggests \
$buildDeps \
<? } else { ?>
&& apk add --no-cache --virtual .build-deps \
linux-headers \
postgresql-dev unixodbc-dev freetds-dev \
aspell-dev \
icu-dev \
openldap-dev \
libjpeg-turbo-dev libpng-dev freetype-dev \
libzip-dev \
zlib-dev \
<? } ?>
\
<? if ($isApacheImage) { ?>
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu \
&& docker-php-ext-configure pdo_dblib --with-libdir=lib/x86_64-linux-gnu \
<? } ?>
<? if ($isApacheImage) { ?>
&& docker-php-ext-configure gd --with-jpeg=/usr/include/ \
--with-freetype=/usr/include/ \
<? } else { ?>
&& docker-php-ext-configure gd --with-jpeg=/usr/include/ \
--with-freetype=/usr/include/ \
<? } ?>
&& docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \
&& docker-php-ext-install \
exif \
gd \
intl \
ldap \
opcache \
pdo_mysql pdo_pgsql pdo_odbc pdo_dblib \
pspell \
sockets \
zip \
<? if ($isApacheImage) { ?>
\
&& a2enmod expires \
headers \
rewrite \
<? } ?>
\
# Cleanup stuff
<? if ($isApacheImage) { ?>
&& apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$buildDeps \
&& rm -rf /var/lib/apt/lists/*
<? } else { ?>
&& apk del .build-deps \
&& rm -rf /var/cache/apk/*
<? } ?>
# Install Roundcube
RUN curl -fL -o /tmp/roundcube.tar.gz \
https://github.com/roundcube/roundcubemail/releases/download/${roundcube_ver}/roundcubemail-${roundcube_ver}.tar.gz \
&& tar -xzf /tmp/roundcube.tar.gz -C /tmp/ \
&& rm -rf /app \
&& mv /tmp/roundcubemail-${roundcube_ver} /app \
\
# Install Composer to resolve Roundcube dependencies
&& curl -fL -o /tmp/composer-setup.php \
https://getcomposer.org/installer \
&& curl -fL -o /tmp/composer-setup.sig \
https://composer.github.io/installer.sig \
&& php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { echo 'Invalid installer' . PHP_EOL; exit(1); }" \
&& php /tmp/composer-setup.php --install-dir=/tmp --filename=composer \
\
# Install tools for building
<? if ($isApacheImage) { ?>
&& apt-get update \
&& toolDeps=" \
git \
unzip \
" \
&& apt-get install -y --no-install-recommends --no-install-suggests \
$toolDeps \
<? } else { ?>
&& apk add --update --no-cache --virtual .tool-deps \
git \
file \
<? } ?>
\
# Resolve Roundcube Composer dependencies
&& mv /app/composer.json-dist /app/composer.json \
&& cd /app/ \
&& (/tmp/composer suggests --list | xargs -i /tmp/composer require {}) \
<? if ($isMinorVerGt5) { ?>
&& /tmp/composer require roundcube/classic \
&& /tmp/composer require roundcube/larry \
<? } ?>
&& /tmp/composer install --no-dev --optimize-autoloader --no-progress \
\
# Resolve Roundcube JS dependencies
&& /app/bin/install-jsdeps.sh \
\
# Make default Roundcube configuration log to syslog
&& sed -i -r 's/^([^\s]{9}log_driver[^\s]{2} =) [^\s]+$/\1 "syslog";/g' \
/app/config/defaults.inc.php \
\
# Setup serve directories
&& cd /app/ \
&& ln -sn ./public_html /app/html \
&& rm -rf /var/www \
&& ln -s /app /var/www \
\
# Set correct owner
&& chown -R www-data:www-data /app /var/www \
\
# Cleanup stuff
&& (find /app/ -name .travis.yml -type f -prune | \
while read d; do rm -rf $d; done) \
&& (find /app/ -name .gitignore -type f -prune | \
while read d; do rm -rf $d; done) \
&& (find /app/ -name .git -type d -prune | \
while read d; do rm -rf $d; done) \
&& (find /app/ -name .github -type d -prune | \
while read d; do rm -rf $d; done) \
<? if ($isApacheImage) { ?>
&& apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$toolDeps \
&& rm -rf /var/lib/apt/lists/* \
<? } else { ?>
&& apk del .tool-deps \
&& rm -rf /var/cache/apk/* \
<? } ?>
/app/temp/* \
/root/.composer \
/tmp/*
# Install configurations
COPY rootfs /
# Fix executable rights
RUN chmod +x /etc/s6-overlay/s6-rc.d/*/run \
/docker-entrypoint.sh \
<? if ($isApacheImage) { ?>
\
# Fix container entrypoint shell usage
&& sed -i -e 's,^#!/bin/sh,#!/bin/bash,' /docker-entrypoint.sh \
<? } ?>
\
# Prepare directory for SQLite database
&& mkdir -p /var/db \
&& chown -R www-data:www-data /var/db
ENV PHP_OPCACHE_REVALIDATION=0 \
PHP_OPCACHE_JIT_BUFFER_SIZE=100M \
SHARE_APP=0
WORKDIR /var/www
ENTRYPOINT ["/init", "/docker-entrypoint.sh"]
<? if ($isApacheImage) { ?>
CMD ["apache2-foreground"]
<? } else { ?>
CMD ["php-fpm"]
<? } ?>