Skip to content

Commit 8ae2f3c

Browse files
authored
Merge pull request #57 from cron-eu/add-vips-ext
Add vips and ffi extensions and PHP_EXTENSIONS setting
2 parents 8afd439 + abc5063 commit 8ae2f3c

File tree

4 files changed

+86
-33
lines changed

4 files changed

+86
-33
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr
3333
RUN <<EOT bash
3434
set -ex
3535
PHP_EXTENSIONS=(
36+
"apcu"
37+
"bcmath"
3638
"bz2"
3739
"calendar"
3840
"exif"
41+
"ffi"
3942
"gd"
4043
"gettext"
4144
"imagick"
@@ -52,6 +55,7 @@ RUN <<EOT bash
5255
"sysvsem"
5356
"sysvshm"
5457
"uuid"
58+
"vips"
5559
"xdebug"
5660
"yaml"
5761
"zip"

README.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ This image includes the following additional extensions:
5454
* bz2
5555
* calendar
5656
* exif
57+
* ffi
5758
* gd
5859
* gettext
5960
* igbinary
@@ -72,11 +73,17 @@ This image includes the following additional extensions:
7273
* sysvsem
7374
* sysvshm
7475
* uuid
76+
* vips
7577
* xdebug
7678
* yaml
7779
* zip
7880

79-
Additionally, it includes the following utilities for TYPO3 specific workflows:
81+
All extensions are enabled by default. If you want to only disable some of them,
82+
you can use the setting `PHP_DISABLE_EXTENSIONS` in the environment variables.
83+
If you want to override the list of enabled extensions, you can use the
84+
`PHP_EXTENSIONS` environment variable.
85+
86+
Additionally, the image includes the following utilities for TYPO3 specific workflows:
8087

8188
* GraphicsMagick
8289
* curl
@@ -141,22 +148,23 @@ Application root is `/app`. Application runs as user `application` (uid=1000).
141148

142149
### Settings (through environment variables)
143150

144-
| Setting | Image | Default | Description |
145-
|----------------------------------------|----------|-------------|------------------------------------------------------------------------------------------------------------------------------------------|
146-
| `XDEBUG_MODE` | fpm, ssh | debug | Or set to `develop` (slow) or `none` to turn it off completely. See https://xdebug.org/docs/all_settings#mode |
151+
| Setting | Image | Default | Description |
152+
|--------------------------------------------|----------|-------------|------------------------------------------------------------------------------------------------------------------------------------------|
153+
| `XDEBUG_MODE` | fpm, ssh | debug | Or set to `develop` (slow) or `none` to turn it off completely. See https://xdebug.org/docs/all_settings#mode |
147154
| `DB_HOST`, `DB_USER`, `DB_PASS`, `DB_NAME` | ssh | | These will create a `.my.cnf` for the user. You can use the same variables in your `docker-compose.yml` to configure the MariaDB image. |
148155
| `APPLICATION_UID`, `APPLICATION_GID` | fpm, ssh | 1000, 1000 | UID and GID for the application user. Change to match your local user in case you use bind-mounts (Linux only) |
149-
| `IMPORT_GITLAB_SERVER` | ssh | git.cron.eu | Gitlab instance to import SSH key from |
150-
| `IMPORT_GITLAB_PUB_KEYS` | ssh | | Gitlab user to import SSH keys from |
151-
| `IMPORT_GITHUB_PUB_KEYS` | ssh | | GitHub user to import SSH keys from |
152-
| `IMPORT_PUB_KEYS` | ssh | | Additional SSH public keys to load, comma separated |
153-
| `SSH_CONFIG` | ssh | | The whole content of the `.ssh/config` file |
154-
| `SSH_KNOWN_HOSTS` | ssh | | The whole content of the `.ssh/known_hosts` file |
155-
| `SSH_PRIVATE_KEY` | ssh | | A SSH private key to load in an `ssh-agent`, useful if you run a SSH container with commands | |
156-
| `ENV` | ssh | | The name of the environment to show on the shell prompt |
157-
| `PHP_INI_OVERRIDE` | fpm, ssh | | Allow overriding php.ini settings. Simply the multiline content for a php.ini here. Use "\n" for multiline i.e. in ECS |
158-
| `PHP_FPM_OVERRIDE` | fpm | | Allow overriding php-fpm pool settings. The multiline content for php-fpm.conf here. Use "\n" for multiline i.e. in ECS |
159-
| `PHP_DISABLE_EXTENSIONS` | fpm, ssh | | Comma separated list of PHP extensions to disable. |
156+
| `IMPORT_GITLAB_SERVER` | ssh | git.cron.eu | Gitlab instance to import SSH key from |
157+
| `IMPORT_GITLAB_PUB_KEYS` | ssh | | Gitlab user to import SSH keys from |
158+
| `IMPORT_GITHUB_PUB_KEYS` | ssh | | GitHub user to import SSH keys from |
159+
| `IMPORT_PUB_KEYS` | ssh | | Additional SSH public keys to load, comma separated |
160+
| `SSH_CONFIG` | ssh | | The whole content of the `.ssh/config` file |
161+
| `SSH_KNOWN_HOSTS` | ssh | | The whole content of the `.ssh/known_hosts` file |
162+
| `SSH_PRIVATE_KEY` | ssh | | A SSH private key to load in an `ssh-agent`, useful if you run a SSH container with commands | |
163+
| `ENV` | ssh | | The name of the environment to show on the shell prompt |
164+
| `PHP_INI_OVERRIDE` | fpm, ssh | | Allow overriding php.ini settings. Simply the multiline content for a php.ini here. Use "\n" for multiline i.e. in ECS |
165+
| `PHP_FPM_OVERRIDE` | fpm | | Allow overriding php-fpm pool settings. The multiline content for php-fpm.conf here. Use "\n" for multiline i.e. in ECS |
166+
| `PHP_EXTENSIONS` | fpm, ssh | (all) | Comma separated list of PHP extensions to enable (if this is not set, all are enabled). |
167+
| `PHP_DISABLE_EXTENSIONS` | fpm, ssh | | Comma separated list of PHP extensions to disable (in case you keep all enabled, you can disable individual ones, i.e. igbinary). |
160168

161169
## Example usage
162170

example-app/.env.docker

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
# See https://xdebug.org/docs/develop#mode
1313
XDEBUG_MODE=debug
1414

15+
# If you only want a specific subset of extensions enabled. This is the default set of all:
16+
#PHP_EXTENSIONS=apcu,bcmath,bz2,calendar,exif,ffi,gd,gettext,imagick,intl,mysqli,opcache,pcntl,pdo_mysql,redis,shmop,soap,sockets,sysvmsg,sysvsem,sysvshm,uuid,vips,xdebug,yaml,zip
17+
# Baseline, minimal set of extensions that are required for most applications
18+
#PHP_EXTENSIONS=apcu,bcmath,bz2,calendar,exif,gd,gettext,intl,mysqli,opcache,pdo_mysql,zip,yaml
19+
1520
# -----------------------------------------
1621
# For the ssh container
1722
# -----------------------------------------

files/entrypoint-extras.sh

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,60 @@
55
#
66
# Mainly tweaking php settings based on ENV variables
77

8+
# Controls which extensions are enabled.
9+
10+
if [ ! -z "${PHP_EXTENSIONS}" ]; then
11+
# If PHP_EXTENSIONS is set: only enable the ones specified
12+
13+
echo "* PHP_EXTENSIONS: $PHP_EXTENSIONS"
14+
echo "* Disabling all extensions and enabling only specified ones."
15+
16+
# First, disable all extensions by renaming them
17+
if ls /usr/local/etc/php/conf.d/docker-php-ext-*.ini 1> /dev/null 2>&1; then
18+
for file in /usr/local/etc/php/conf.d/docker-php-ext-*.ini; do
19+
mv "$file" "$file.disabled"
20+
done
21+
fi
22+
23+
# Now, enable the extensions listed in PHP_EXTENSIONS
24+
for ext in $(echo "$PHP_EXTENSIONS" | sed -e 's/,/ /g'); do
25+
disabled_ext_file="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini.disabled"
26+
enabled_ext_file="/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini"
27+
28+
if [ -f "$disabled_ext_file" ]; then
29+
echo "* Enabling PHP extension: $ext"
30+
mv "$disabled_ext_file" "$enabled_ext_file"
31+
elif [ -f "$enabled_ext_file" ]; then
32+
# This case should not happen if the above disabling loop worked, but as a fallback.
33+
echo "* PHP extension $ext was already enabled."
34+
else
35+
echo "* WARNING: PHP extension $ext not found, cannot enable."
36+
fi
37+
done
38+
else
39+
# If PHP_EXTENSIONS is not set, all extensions are enabled by default.
40+
41+
# Enable all extensions which might have been disabled at some point first
42+
if ls /usr/local/etc/php/conf.d/*php-ext*.disabled 1> /dev/null 2>&1; then
43+
for file in /usr/local/etc/php/conf.d/*php-ext*.disabled; do
44+
mv "$file" "${file%.disabled}"
45+
done
46+
fi
47+
# Disable extensions based on PHP_DISABLE_EXTENSIONS
48+
if [ ! -z "${PHP_DISABLE_EXTENSIONS}" ]; then
49+
for ext in $(echo $PHP_DISABLE_EXTENSIONS | sed -e 's/,/ /g'); do
50+
if [ -f "/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini" ]; then
51+
echo "* Disabling PHP extension: $ext"
52+
mv /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini.disabled
53+
else
54+
echo "* WARNING: PHP extension $ext not found, cannot disable"
55+
fi
56+
done
57+
fi
58+
fi
59+
60+
# Special handling for XDEBUG through XDEBUG_MODE:
61+
862
# Really disable XDEBUG if not required
963
if [ -z "${XDEBUG_MODE}" ] || [ "${XDEBUG_MODE}" = "off" ]; then
1064
# completely not load xdebug if its off
@@ -14,24 +68,6 @@ else
1468
echo "zend_extension=xdebug.so" > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
1569
fi
1670

17-
# Enable all extensions which might have been disabled at some point first
18-
if ls /usr/local/etc/php/conf.d/*php-ext*.disabled 1> /dev/null 2>&1; then
19-
for file in /usr/local/etc/php/conf.d/*php-ext*.disabled; do
20-
mv "$file" "${file%.disabled}"
21-
done
22-
fi
23-
# Disable extensions based on PHP_DISABLE_EXTENSIONS
24-
if [ ! -z "${PHP_DISABLE_EXTENSIONS}" ]; then
25-
for ext in $(echo $PHP_DISABLE_EXTENSIONS | sed -e 's/,/ /g'); do
26-
if [ -f "/usr/local/etc/php/conf.d/docker-php-ext-$ext.ini" ]; then
27-
echo "* Disabling PHP extension: $ext"
28-
mv /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini /usr/local/etc/php/conf.d/docker-php-ext-$ext.ini.disabled
29-
else
30-
echo "* WARNING: PHP extension $ext not found, cannot disable"
31-
fi
32-
done
33-
fi
34-
3571
if [ ! -z "${APPLICATION_UID}" ]; then
3672
echo "* Change uid of 'application' user to $APPLICATION_UID"
3773
usermod -u $APPLICATION_UID application

0 commit comments

Comments
 (0)