Allow to start fpfis/httpd-php-dev with xdebug and/or blackfire disabled
Normally, a developer has XDebug disabled during development. They enable the PHP xdebug
module only for debug puroposed. However, fpfis/httpd-php-dev
starts with xdebug
and blackfire
PHP modules enabled. Every time when I get up the container, I have to run this command:
$ phpdis xdebug blackfire
But we can add build args that can be set from docker-compose.yml
, so that projects can decide to start with xdebug
and/or blackfire
disabled:
version: '3'
services:
web:
build:
context: .
args:
- xdebug_enabled="0"
- blackfire_enabled="0"
...
Then, in Dockerfile
we can default the new arguments to preserve the current behaviour.
As, I've mentioned in #3 (closed), I cannot fork or post a merge request against this project repo, so I'll attach a patch that fixes this issue, here:disable-xdebug-blackfire.patch with this diff:
diff --git a/Dockerfile b/Dockerfile
index 7c79035..10c29b6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -74,6 +74,8 @@ RUN /scripts/install-ci.sh && \
FROM httpd-php-ci as httpd-php-dev
ADD supervisor_conf/shell.conf /etc/supervisor/conf.d
ARG dev_packages="php${php_version}-xdebug"
+ARG xdebug_enabled="1"
+ARG blackfire_enabled="1"
ADD scripts/install-dev.sh /scripts/
RUN /scripts/install-dev.sh && \
phpdismod 95-prod && \
diff --git a/README.md b/README.md
index 5af76e1..bf5e383 100644
--- a/README.md
+++ b/README.md
@@ -62,17 +62,19 @@ docker build --build-arg php_version=5.6 --target httpd-php -t fpfis/httpd-php:5
The [Dockerfile](Dockerfile) is a multistage file containing multiple targets to build
## Build arguments
-| arg | Description | Default
-|------------------|------------------------------------------------|----------
-|`php_version` | Version of php to build | `5.6`
-|`php_modules` | List of PHP extensions to install | `curl soap bz2 calendar exif mysql opcache zip xsl intl mcrypt yaml mbstring ldap sockets iconv gd redis memcached tidy`
-|`oci8_version` | Version of oci8 library to install (full) | `2.0.12`
-|`apache2_modules` | List of Apache modules to enable after install | `proxy_fcgi setenvif rewrite`
-|`dev_packages` | Additional packages to install the dev image | `gnupg wget curl nano unzip patch git rsync make php${php_version}-xdebug`
-|`composer_version`| Version of Composer to install the dev image | `1.9.3`
-|`drush_version` | Version of Drush to install the dev image | `8.2.3`
-|`USER_ID` | User ID to use for Apache and PHP | `1000`
-|`GROUP_ID` | Group ID to use for Apache and PHP | `1000`
+| arg | Description | Default
+|-------------------|------------------------------------------------|----------
+|`php_version` | Version of php to build | `5.6`
+|`php_modules` | List of PHP extensions to install | `curl soap bz2 calendar exif mysql opcache zip xsl intl mcrypt yaml mbstring ldap sockets iconv gd redis memcached tidy`
+|`oci8_version` | Version of oci8 library to install (full) | `2.0.12`
+|`apache2_modules` | List of Apache modules to enable after install | `proxy_fcgi setenvif rewrite`
+|`dev_packages` | Additional packages to install the dev image | `gnupg wget curl nano unzip patch git rsync make php${php_version}-xdebug`
+|`xdebug_enabled` | If XDebug is enabled on start | `1`
+|`blackfire_enabled`| If Blackfire is enabled on start | `1`
+|`composer_version` | Version of Composer to install the dev image | `1.9.3`
+|`drush_version` | Version of Drush to install the dev image | `8.2.3`
+|`USER_ID` | User ID to use for Apache and PHP | `1000`
+|`GROUP_ID` | Group ID to use for Apache and PHP | `1000`
## Contribute
diff --git a/scripts/install-dev.sh b/scripts/install-dev.sh
index 34feaea..8243782 100755
--- a/scripts/install-dev.sh
+++ b/scripts/install-dev.sh
@@ -23,3 +23,13 @@ apt-get clean
rm -rf /var/lib/apt/lists/*
rm -rf /tmp/*
rm -Rf /root/.composer/cache
+
+if [ "${xdebug_enabled}" != "1" ]
+then
+ phpdismod xdebug
+fi
+
+if [ "${blackfire_enabled}" != "1" ]
+then
+ phpdismod blackfire
+fi