-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathDockerfile
353 lines (319 loc) · 12.5 KB
/
Dockerfile
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# My php-fpm image, based on alpine Linux, configured and forked from the
# official PHP docker repository.
# @see: https://store.docker.com/images/php
FROM php:8.4-fpm-alpine
LABEL org.opencontainers.image.title="llaumgui/php-fpm"
LABEL org.opencontainers.image.description="Fork of php-fpm:8.4"
LABEL org.opencontainers.image.vendor="Guillaume Kulakowski"
LABEL org.opencontainers.image.authors="[email protected]"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.version="8.4"
# ---------------------------------------------------------- Setup build options
ARG DOCKER_PHP_ENABLE_APCU="on"
ARG DOCKER_PHP_ENABLE_COMPOSER="on"
ARG DOCKER_PHP_ENABLE_EXIF="on"
ARG DOCKER_PHP_ENABLE_IMAGICK="on"
ARG DOCKER_PHP_ENABLE_FFMPEG="on"
ARG DOCKER_PHP_ENABLE_LDAP="on"
ARG DOCKER_PHP_ENABLE_MEMCACHED="on"
ARG DOCKER_PHP_ENABLE_MONGODB="on"
ARG DOCKER_PHP_ENABLE_MYSQL="on"
ARG DOCKER_PHP_ENABLE_POSTGRESQL="on"
ARG DOCKER_PHP_ENABLE_REDIS="on"
ARG DOCKER_PHP_ENABLE_SYMFONY="on"
ARG DOCKER_PHP_ENABLE_XDEBUG="off"
# Fix hadolint #DL4006 (https://github.com/hadolint/hadolint/wiki/DL4006)
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
RUN echo "With apcu support: " ; if [ "${DOCKER_PHP_ENABLE_APCU}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With composer support: " ; if [ "${DOCKER_PHP_ENABLE_COMPOSER}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With exif support: " ; if [ "${DOCKER_PHP_ENABLE_EXIF}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With imagick support: " ; if [ "${DOCKER_PHP_ENABLE_IMAGICK}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With ffmpeg support: " ; if [ "${DOCKER_PHP_ENABLE_FFMPEG}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With ldap support: " ; if [ "${DOCKER_PHP_ENABLE_LDAP}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With memcached support: " ; if [ "${DOCKER_PHP_ENABLE_MEMCACHED}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With mongodb support: " ; if [ "${DOCKER_PHP_ENABLE_MONGODB}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With mysql support: " ; if [ "${DOCKER_PHP_ENABLE_MYSQL}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With postgresql support: " ; if [ "${DOCKER_PHP_ENABLE_POSTGRESQL}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With redis support: " ; if [ "${DOCKER_PHP_ENABLE_REDIS}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With symfony support: " ; if [ "${DOCKER_PHP_ENABLE_SYMFONY}" = "on" ] ; then echo "Yes"; else echo "No" ; fi && \
echo "With xdebug support: " ; if [ "${DOCKER_PHP_ENABLE_XDEBUG}" = "on" ] ; then echo "Yes"; else echo "No" ; fi
# --------------------------------------------------------- Install dependancies
RUN apk add --update --no-cache \
# Dependencies for gd \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
# Dependancy for gmp \
gmp \
libgmpxx \
# Dependancy for intl \
icu-libs \
libintl \
# Dependancy for zip \
libzip \
unzip \
# Misc tools \
coreutils \
fcgi \
git \
patch \
tzdata
# --------------------------------------------------- Install build dependancies
RUN apk add --update --no-cache --virtual .docker-php-global-dependancies \
# Build dependency for gettext \
gettext-dev \
# Build dependency for gmp \
gmp-dev \
# Build dependency for intl \
icu-dev \
# Build dependency for mbstring \
oniguruma-dev \
# Build dependencies for XML part \
libxml2-dev \
ldb-dev \
# Build dependencies for Zip \
libzip-dev \
# Build dependancies for Pecl \
autoconf \
g++ \
make \
# Build dependancy for APCu \
pcre-dev \
# Misc build dependancy \
wget
# ------------------------------------------------------- Install php extensions
RUN php -m && \
docker-php-ext-configure bcmath --enable-bcmath && \
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg && \
docker-php-ext-configure gettext && \
docker-php-ext-configure gmp && \
docker-php-ext-configure intl --enable-intl && \
docker-php-ext-configure mbstring --enable-mbstring && \
docker-php-ext-configure opcache --enable-opcache && \
docker-php-ext-configure pcntl --enable-pcntl && \
docker-php-ext-configure soap && \
docker-php-ext-configure zip && \
docker-php-ext-install bcmath \
gd \
gettext \
gmp \
intl \
mbstring \
opcache \
pcntl \
shmop \
soap \
sysvsem \
zip && \
php -m
# -------------------------------------------------- Install php-fpm-healthcheck
RUN sed -i 's#^;pm.status_path = .*#pm.status_path = /status#g' /usr/local/etc/php-fpm.d/www.conf && \
wget --progress=dot:giga -O /usr/local/bin/php-fpm-healthcheck https://raw.githubusercontent.com/renatomefi/php-fpm-healthcheck/master/php-fpm-healthcheck && \
chmod +x /usr/local/bin/php-fpm-healthcheck
# --------------------------------------------------- Conditionnal installations
# Enable APCu
RUN if [ "${DOCKER_PHP_ENABLE_APCU}" != "off" ]; then \
printf "\n" | pecl install apcu && \
docker-php-ext-enable apcu && \
php -m; \
else \
echo "Skip apcu support"; \
fi
# Enable EXIF
RUN if [ "${DOCKER_PHP_ENABLE_EXIF}" != "off" ]; then \
docker-php-ext-install exif && \
docker-php-ext-enable exif && \
php -m; \
else \
echo "Skip apcu support"; \
fi
# Enable imagick
RUN if [ "${DOCKER_PHP_ENABLE_IMAGICK}" != "off" ]; then \
# Dependancy for imagick \
apk add --update --no-cache \
imagemagick \
imagemagick-libs \
libgomp && \
# Build dependancy for imagick \
apk add --update --no-cache --virtual .docker-php-imagick-dependancies \
imagemagick-dev && \
#printf "\n" | pecl install imagick && \
# Tempory workaround - BEGIN \
git clone https://github.com/Imagick/imagick.git --depth 1 /tmp/imagick && \
cd /tmp/imagick && \
git fetch origin master && \
git switch master && \
cd /tmp/imagick && \
sed -i 's/php_strtolower/zend_str_tolower/g' imagick.c && \
phpize && \
./configure && \
make && \
make install && \
# Tempory workaround - END \
docker-php-ext-enable imagick && \
apk del .docker-php-imagick-dependancies && \
php -m; \
else \
echo "Skip imagick support"; \
fi
# Enable ffmpeg
RUN if [ "${DOCKER_PHP_ENABLE_FFMPEG}" != "off" ]; then \
apk add --update --no-cache \
ffmpeg; \
else \
echo "Skip ffmpeg support"; \
fi
# Enable LDAP
RUN if [ "${DOCKER_PHP_ENABLE_LDAP}" != "off" ]; then \
# Dependancy for ldap \
apk add --update --no-cache \
libldap && \
# Build dependancy for ldap \
apk add --update --no-cache --virtual .docker-php-ldap-dependancies \
openldap-dev && \
docker-php-ext-configure ldap && \
docker-php-ext-install ldap && \
apk del .docker-php-ldap-dependancies && \
php -m; \
else \
echo "Skip ldap support"; \
fi
# Enable Memcached
RUN if [ "${DOCKER_PHP_ENABLE_MEMCACHED}" != "off" ]; then \
# Dependancy for ldap \
apk add --update --no-cache \
libevent \
libmemcached-libs && \
# Build dependancies for memcached \
apk add --update --no-cache --virtual .docker-php-memcached-dependancies \
cyrus-sasl-dev \
libevent-dev \
libmemcached-dev && \
printf "\n" | pecl install memcached && \
docker-php-ext-enable memcached && \
apk del .docker-php-memcached-dependancies && \
php -m; \
else \
echo "Skip memcached support"; \
fi
# Enable MongoDB
RUN if [ "${DOCKER_PHP_ENABLE_MONGODB}" != "off" ]; then \
apk add --update --no-cache --virtual .docker-php-mongodb-dependancies \
# Dependancies for MongoDB \
heimdal-dev && \
printf "\n" | pecl install mongodb && \
docker-php-ext-enable mongodb && \
apk del .docker-php-mongodb-dependancies && \
php -m; \
else \
echo "Skip mongodb support"; \
fi
# Enable MySQL
RUN if [ "${DOCKER_PHP_ENABLE_MYSQL}" != "off" ]; then \
apk add --update --no-cache --virtual .docker-php-mysql-dependancies \
# Dependancy for mysql \
mysql-client && \
# MySQLnd is already compiled. \
# See: https://github.com/docker-library/php/issues/167 \
docker-php-ext-configure mysqli && \
docker-php-ext-configure pdo_mysql && \
docker-php-ext-install mysqli \
pdo_mysql && \
apk del .docker-php-mysql-dependancies && \
php -m; \
else \
echo "Skip mysql support"; \
fi
# Enable PostgreSQL
RUN if [ "${DOCKER_PHP_ENABLE_POSTGRESQL}" != "off" ]; then \
# Dependancy for PostgreSQL \
apk add --update --no-cache \
libpq && \
# Build dependancies for PostgreSQL \
apk add --update --no-cache --virtual .docker-php-postgresql-dependancies \
libpq-dev && \
docker-php-ext-configure pdo_pgsql && \
docker-php-ext-configure pgsql && \
docker-php-ext-install \
pdo_pgsql \
pgsql && \
apk del .docker-php-postgresql-dependancies && \
php -m; \
else \
echo "Skip postgresql support"; \
fi
# Enable Redis
RUN if [ "${DOCKER_PHP_ENABLE_REDIS}" != "off" ]; then \
printf "\n" | pecl install redis && \
docker-php-ext-enable redis && \
php -m; \
else \
echo "Skip redis support"; \
fi
# Enable Symfony extensions
RUN if [ "${DOCKER_PHP_ENABLE_SYMFONY}" != "off" ]; then \
# Dependancy for PostgreSQL \
apk add --update --no-cache \
yaml && \
# Build dependancy for YAML \
apk add --update --no-cache --virtual .docker-php-symfony-dependancies \
yaml-dev && \
printf "\n" | pecl install yaml && \
docker-php-ext-enable yaml; \
apk del .docker-php-symfony-dependancies && \
php -m; \
else \
echo "Skip symfony support"; \
fi
# Enable Xdebug
RUN if [ "${DOCKER_PHP_ENABLE_XDEBUG}" != "off" ]; then \
# Build dependancy for XDebug \
apk add --update --no-cache --virtual .docker-php-xdebug-dependancies \
bash \
git \
linux-headers && \
git clone https://github.com/xdebug/xdebug.git && \
cd xdebug && \
./rebuild.sh && \
docker-php-ext-enable xdebug && \
echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini && \
rm -rf xdebug && \
apk del .docker-php-xdebug-dependancies && \
php -m; \
else \
echo "Skip xdebug support"; \
fi
# --------------------------------------------- Conditionnal tools installations
# Install composer.
RUN if [ "${DOCKER_PHP_ENABLE_COMPOSER}" != "off" ]; then \
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) && \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") && \
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then \
>&2 echo 'ERROR: Invalid installer signature' && \
rm composer-setup.php && \
exit 1; \
else \
php composer-setup.php --install-dir=/usr/bin --filename=composer && \
RESULT=$? && \
rm composer-setup.php && \
exit $RESULT && \
composer -V; \
fi; \
else \
echo "Skip composer support"; \
fi
# ---------------------------------------------------------------- Configuration
# My configuration.
RUN sed -i "s/^;security.limit_extensions =.*/security.limit_extensions = .php .php8 .php84/g" /usr/local/etc/php-fpm.d/www.conf
COPY php.d /usr/local/etc/php/conf.d
COPY etc /usr/local/etc/php
# Big clean
RUN apk del .docker-php-global-dependancies && \
rm -rf /var/cache/apk/* && \
docker-php-source delete
# Healthcheck
HEALTHCHECK --interval=1m --timeout=10s --start-period=1m --retries=3 CMD FCGI_CONNECT=localhost:9000 php-fpm-healthcheck
EXPOSE 9000
WORKDIR /var/www