Skip to content

Commit 6a09547

Browse files
committed
Build using mlocati/docker-php-extension-installer
1 parent 41ea7e7 commit 6a09547

File tree

3 files changed

+36
-47
lines changed

3 files changed

+36
-47
lines changed

Dockerfile

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# -------- Copy stuff from base images
2+
ARG PHP_VER=7.2.29
3+
ARG OS_VER=3.10
24

35
FROM jwilder/dockerize:0.6.0 AS dockerize
46
FROM bashitup/alpine-tools:latest AS tools
5-
FROM php:7.2.29-fpm-alpine3.10
7+
FROM php:$PHP_VER-fpm-alpine$OS_VER
68

79
COPY --from=dockerize /usr/local/bin/dockerize /usr/bin/
810

911
COPY --from=tools /bin/yaml2json /usr/bin/
1012
COPY --from=tools /bin/modd /usr/bin/
1113
COPY --from=tools /bin/jq /usr/bin/
1214

15+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
1316
# -------- Add packages and build/install tools
1417

1518
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php
@@ -19,32 +22,10 @@ RUN apk --no-cache add \
1922
&& \
2023
apk --update add \
2124
bash nginx nginx-mod-http-lua nginx-mod-http-lua-upstream \
22-
supervisor ncurses certbot \
23-
git wget curl libcurl openssh-client ca-certificates \
24-
dialog libpq icu-libs imap-dev libzip \
25-
libmcrypt libxslt libpng freetype libjpeg-turbo \
25+
supervisor ncurses certbot git wget curl openssh-client ca-certificates \
26+
dialog \
2627
&& \
27-
apk add --virtual .build-deps \
28-
autoconf gcc make musl-dev linux-headers libffi-dev libzip-dev \
29-
augeas-dev python-dev icu-dev sqlite-dev openssl-dev \
30-
libmcrypt-dev libxslt-dev libpng-dev freetype-dev libjpeg-turbo-dev \
31-
&& \
32-
docker-php-ext-configure gd \
33-
--with-gd \
34-
--with-freetype-dir=/usr/include/ --with-png-dir=/usr/include/ \
35-
--with-jpeg-dir=/usr/include/ \
36-
&& \
37-
docker-php-ext-configure zip --with-libzip=/usr/include \
38-
&& \
39-
docker-php-ext-configure imap --with-imap --with-imap-ssl \
40-
&& \
41-
docker-php-ext-install \
42-
pdo_mysql mysqli \
43-
imap gd exif intl xsl soap zip opcache && \
44-
pecl install xdebug mcrypt-1.0.3 && \
45-
docker-php-ext-enable mcrypt && \
46-
docker-php-source delete && \
47-
apk del .build-deps
28+
install-php-extensions mcrypt pdo_mysql mysqli gd exif intl zip opcache
4829

4930
# -------- Setup composer and runtime environment
5031

README.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ If you want extreme backward compatibility with the default settings of `richarv
163163
* `NGINX_READABLE=.` and `NGINX_WRITABLE=.`, to make the entire codebase readable and writable by nginx+php (which is much less secure)
164164
* `NGINX_WORKERS=auto`
165165
* `PHP_LOG_ERRORS=false`
166+
* `EXTRA_EXTS=pgsql pdo_pgsql redis xsl soap xdebug` (if you need any of these extensions)
167+
* `EXTRA_APKS=nginx-mod-http-geoip nginx-mod-stream-geoip` (if you need nginx geoip modules)
166168

167169
The following features of `richarvey/nginx-php-fpm` are not directly supported by this image, and must be configured in a different way:
168170

@@ -213,9 +215,8 @@ services:
213215
build:
214216
context: https://github.com/dirtsimple/php-server.git
215217
args:
216-
- EXTRA_APKS=ghostscript graphviz aspell-dev libmemcached-dev cyrus-sasl-dev openldap-dev
217-
- EXTRA_EXTS=xmlrpc pspell ldap
218-
- EXTRA_PECL=memcached
218+
- EXTRA_APKS=ghostscript graphviz
219+
- EXTRA_EXTS=xmlrpc pspell ldap memcached
219220
environment:
220221
- GIT_REPO=https://github.com/moodle/moodle.git
221222
- GIT_BRANCH=MOODLE_33_STABLE
@@ -227,6 +228,8 @@ For performance's sake, it's generally better to specify extras at build-time, b
227228
228229
Specific versions of a PECL module can be forced by using a `:`, e.g. `EXTRA_PECL=mcrypt:1.0.2`. (A `:` is used in place of a `-` so that the version can be stripped from the extension name in generated PHP .ini file(s).)
229230

231+
As of the 2.x versions of this image, `EXTRA_EXTS` are built using [mlocati/docker-php-extension-installer](https://github.com/mlocati/docker-php-extension-installer/), so you no longer need to specify `EXTRA_APKS` for any of the extensions it supports, and you can build supported PECL extensions using `EXTRA_EXTS`, without needing `EXTRA_PECL`, unless you need to specify a particular module version, or need an extension that isn't supported by docker-php-extension-installer. (But in such cases, you must explicitly list any needed packages in `EXTRA_APKS`, since the automatic installer won't be handling it for you.)
232+
230233
### Supervised Tasks
231234

232235
Any files named `/etc/supervisor.d/*.ini` are included as part of the supervisord configuration, so that you can add your own supervised tasks. (For example, if you wanted to add a mysql or openssh server.) This image's own tasks are there as well, and can be overridden by your own substitutions in `/tpl/etc/supervisor.d` or a `DOCKERIZE_TEMPLATES` directory:
@@ -259,23 +262,27 @@ Please note that the modd process runs as **root**, which means that your config
259262

260263
### Version Info
261264

262-
Builds of this image are tagged with multiple aliases to make it easy to pin specific revisions or to float by PHP version. For example, a PHP 7.1.33 image with revision 1.4.6 of this container could be accessed via any of the following tags:
265+
Builds of this image are tagged with multiple aliases to make it easy to pin specific revisions or to float by PHP version. For example, a PHP 7.1.33 image with release 1.4.6 of this container could be accessed via any of the following tags:
263266

264-
* `7.1`, `7.1.33` - PHP version, with or without minor release, any container revision
265-
* `7.1-1.x`, `7.1.33-1.x` -- PHP version plus container major revision
266-
* `7.1.33-1.4.6 -- an exact revision of both PHP and the container
267+
* `7.1`, `7.1.33` - PHP version, with or without minor version, latest container release
268+
* `7.1-1.x`, `7.1.33-1.x` -- PHP version plus container major release
269+
* `7.1.33-1.4.6` -- an exact PHP revision and container release
267270

268-
The `latest` tag will match the highest-numbered exact revision, while `unstable` tracks the `master` branch during development.
271+
The `unstable` tag tracks the `master` branch during development, with the highest PHP version currently in test.
269272

270273
#### Version History
271274

272-
| Tags | Upstream Version | PHP | nginx | mod lua | alpine |
273-
| ------------- | ------------------------------------------------------------ | ------ | ------ | ------- | ------ |
274-
| 1.0.x - 1.3.x | [1.3.10](https://gitlab.com/ric_harvey/nginx-php-fpm/tree/1.3.10) | 7.1.12 | 1.13.7 | 0.10.11 | 3.6 |
275-
| 1.4.0 | N/A | 7.1.32 | 1.14.2 | 0.10.15 | 3.9 |
276-
| 1.4.x | N/A | 7.1.33 | 1.14.2 | 0.10.15 | 3.9 |
277-
| 7.1.33-1.4.x | N/A | 7.1.33 | 1.14.2 | 0.10.15 | 3.9 |
278-
| 7.2.26-1.4.x | N/A | 7.2.26 | 1.14.2 | 0.10.15 | 3.9 |
279-
| 7.2.29-2.0.x | N/A | 7.2.29 | 1.16.2 | 0.10.15 | 3.10 |
280-
281-
(Note: The 2.x version bump for 7.2.29 is due to the switch from alpine 3.9 to 3.10: if you're building complex things on top of this image, the base OS often matters quite a bit.)
275+
| Tags | PHP | nginx | mod lua | alpine | Notes |
276+
| ------------- | ------ | ------ | ------- | ------ | ----- |
277+
| 7.2.29-2.0.x | 7.2.29 | 1.16.2 | 0.10.15 | 3.10 | New extension build method for all 7.x-2.x versions |
278+
| 7.2.26-2.0.x | 7.2.26 | 1.14.2 | 0.10.15 | 3.9 ||
279+
| 7.1.33-2.0.x | 7.1.33 | 1.14.2 | 0.10.15 | 3.9 ||
280+
| | | | | |   |
281+
| 7.2.26-1.4.x | 7.2.26 | 1.14.2 | 0.10.15 | 3.9 | Old extension build method used from here down |
282+
| 7.1.33-1.4.x | 7.1.33 | 1.14.2 | 0.10.15 | 3.9 ||
283+
| | | | | |   |
284+
| 1.4.x | 7.1.33 | 1.14.2 | 0.10.15 | 3.9 ||
285+
| 1.4.0 | 7.1.32 | 1.14.2 | 0.10.15 | 3.9 ||
286+
| 1.0.x - 1.3.x | 7.1.12 | 1.13.7 | 0.10.11 | 3.6 | Based on upstream [1.3.10][ric_harvey] |
287+
288+
[ric_harvey]: https://gitlab.com/ric_harvey/nginx-php-fpm/tree/1.3.10

scripts/install-extras

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ uninstalled_apks() {
77
}
88

99
uninstalled_exts() {
10-
ext_base="/usr/local/etc/php/conf.d/docker-php-ext-"
11-
for ext; do [ -f "${ext_base}${ext%:*}.ini" ] || echo $ext; done
10+
local exts=($(php -m)) ext_base="/usr/local/etc/php/conf.d/docker-php-ext-"
11+
shopt -s nocaseglob
12+
for ext; do [[ " ${exts[*]} " == *"$ext"* || -f "${ext_base}${ext%:*}.ini" ]] || echo $ext; done
1213
}
1314

1415
install_pecls() {
@@ -27,6 +28,6 @@ installs=$(uninstalled_exts $EXTRA_EXTS)
2728
pecls=$( uninstalled_exts $EXTRA_PECL)
2829

2930
if [[ "$apks" ]]; then apk add $apks; fi
30-
if [[ "$installs" ]]; then docker-php-ext-install $installs; fi
31+
if [[ "$installs" ]]; then install-php-extensions $installs; fi
3132
if [[ "$pecls" ]]; then install_pecls $pecls; fi
3233

0 commit comments

Comments
 (0)