Skip to content

Commit

Permalink
Feature/use rename for php debugger switch (#107)
Browse files Browse the repository at this point in the history
* Don't install pysed

* Don't disable blackfire by default

* Delete PHP debugger ini files instead of disabling

Because the container is stateless, removing is good enough.

* Update documentation
  • Loading branch information
choonge authored and mblaschke committed Jun 27, 2016
1 parent aca8af8 commit b6e1d45
Show file tree
Hide file tree
Showing 136 changed files with 1,308 additions and 2,465 deletions.
2 changes: 1 addition & 1 deletion docker/bootstrap/alpine-3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RUN set -x \
py-paramiko \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/bin/ansible* \
# Cleanup
&& apk del python-dev
2 changes: 1 addition & 1 deletion docker/bootstrap/centos-7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUN set -x \
&& easy_install pip \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/bin/ansible* \
&& yum erase -y python-devel \
&& yum clean all
2 changes: 1 addition & 1 deletion docker/bootstrap/debian-7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
build-essential \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/local/bin/ansible* \
# Cleanup
&& apt-get purge -y -f --force-yes \
Expand Down
2 changes: 1 addition & 1 deletion docker/bootstrap/debian-8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
build-essential \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/local/bin/ansible* \
# Cleanup
&& apt-get purge -y -f --force-yes \
Expand Down
2 changes: 1 addition & 1 deletion docker/bootstrap/debian-9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
build-essential \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/local/bin/ansible* \
# Cleanup
&& apt-get purge -y -f --force-yes \
Expand Down
2 changes: 1 addition & 1 deletion docker/bootstrap/ubuntu-12.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
apt-transport-https \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/local/bin/ansible* \
# Cleanup
&& apt-get purge -y -f --force-yes \
Expand Down
2 changes: 1 addition & 1 deletion docker/bootstrap/ubuntu-14.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
build-essential \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/local/bin/ansible* \
# Cleanup
&& apt-get purge -y -f --force-yes \
Expand Down
2 changes: 1 addition & 1 deletion docker/bootstrap/ubuntu-15.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
build-essential \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/local/bin/ansible* \
# Cleanup
&& apt-get purge -y -f --force-yes \
Expand Down
2 changes: 1 addition & 1 deletion docker/bootstrap/ubuntu-15.10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
build-essential \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/local/bin/ansible* \
# Cleanup
&& apt-get purge -y -f --force-yes \
Expand Down
2 changes: 1 addition & 1 deletion docker/bootstrap/ubuntu-16.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
build-essential \
&& pip install --upgrade pip \
&& hash -r \
&& pip install ansible pysed \
&& pip install ansible \
&& chmod 750 /usr/local/bin/ansible* \
# Cleanup
&& apt-get purge -y -f --force-yes \
Expand Down
8 changes: 4 additions & 4 deletions docker/php-apache-dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ Variable | Description
`CLI_SCRIPT` | Predefined CLI script for service
`APPLICATION_UID` | PHP-FPM UID (Effective user ID)
`APPLICATION_GID` | PHP-FPM GID (Effective group ID)
`WEB_DOCUMENT_ROOT` | Document root for Nginx
`WEB_DOCUMENT_INDEX` | Document index (eg. `index.php`) for Nginx
`WEB_ALIAS_DOMAIN` | Alias domains (eg. `*.vm`) for Nginx

`WEB_DOCUMENT_ROOT` | Document root for Apache
`WEB_DOCUMENT_INDEX` | Document index (eg. `index.php`) for Apache
`WEB_ALIAS_DOMAIN` | Alias domains (eg. `*.vm`) for Apache
`PHP_DEBUGGER` | Either `xdebug`, `blackfire` or `none`. Default is `xdebug`.

## Container info

Expand Down
Original file line number Diff line number Diff line change
@@ -1,63 +1,56 @@
#!/usr/bin/env bash
#
# Debugger switch
#

function phpModuleEnable() {
for PHP_FILE in $*; do
if [[ -f "$PHP_FILE" ]]; then
pysed -r '^[; ]*((zend_)?(extension=.*))$' '\1' "$PHP_FILE" --write
fi
done
}
PHP_CONF_PATHS="
/etc/php5/conf.d
/etc/php7/conf.d
/etc/php.d
/etc/php5/mods-available
/etc/php5/cli/conf.d
/etc/php5/cli/conf.d
/etc/php5/fpm/conf.d
/etc/php5/fpm/conf.d
/etc/php/7.0/mods-available
/etc/php/7.0/cli/conf.d
/etc/php/7.0/fpm/conf.d"

function phpModuleRemove() {
if [ "$#" -ne 1 ]; then
echo "You must specify the name of the PHP module which you want to disable"
exit 1
fi

function phpModuleDisable() {
for PHP_FILE in $*; do
if [[ -f "$PHP_FILE" ]]; then
pysed -r '^[; ]*((zend_)?(extension=.*))$' ';\1' "$PHP_FILE" --write
fi
echo " - Removing PHP module ${1}"
for CONF_PATH in $PHP_CONF_PATHS; do
rm -f "${CONF_PATH}"/*"${1}".ini

This comment has been minimized.

Copy link
@guiyomh

guiyomh Jun 28, 2016

Member

It's not a disable function :(

A simple mv would have is enough.
What would have allowed to change between xdebug/blacfire without restart the container.

This comment has been minimized.

Copy link
@mblaschke

mblaschke Jun 28, 2016

Member

ok, then let's change it for the next version

done
}

PHP_XDEBUG_FILES="
/etc/php5/conf.d/xdebug.ini
/etc/php7/conf.d/xdebug.ini
/etc/php.d/xdebug.ini
/etc/php5/mods-available/xdebug.ini
/etc/php5/cli/conf.d/20-xdebug.ini
/etc/php5/cli/conf.d/xdebug.ini
/etc/php5/fpm/conf.d/20-xdebug.ini
/etc/php5/fpm/conf.d/xdebug.ini
/etc/php/7.0/mods-available/xdebug.ini
/etc/php/7.0/cli/conf.d/20-xdebug.ini
/etc/php/7.0/fpm/conf.d/20-xdebug.ini"

PHP_BLACKFIRE_FILES="
/etc/php.d/zz-blackfire.ini
/etc/php5/conf.d/90-blackfire.ini
/etc/php5/conf.d/zz-blackfire.ini
/etc/php5/cli/conf.d/90-blackfire.ini
/etc/php5/cli/conf.d/zz-blackfire.ini
/etc/php5/fpm/conf.d/90-blackfire.ini
/etc/php5/fpm/conf.d/zz-blackfire.ini
/etc/php/7.0/cli/conf.d/90-blackfire.ini
/etc/php/7.0/fpm/conf.d/90-blackfire.ini"

if [[ -n "${PHP_DEBUGGER+x}" ]]; then
case "$PHP_DEBUGGER" in
xdebug)
echo "PHP-Debugger: Xdebug enabled"
phpModuleRemove "blackfire"
;;

blackfire)
echo "PHP-Debugger: Blackfire enabled"
phpModuleEnable $PHP_BLACKFIRE_FILES
phpModuleDisable $PHP_XDEBUG_FILES
phpModuleRemove "xdebug"
;;

none)
echo "PHP-Debugger: none"
phpModuleDisable $PHP_BLACKFIRE_FILES
phpModuleDisable $PHP_XDEBUG_FILES
phpModuleRemove "blackfire"
phpModuleRemove "xdebug"
;;
esac

else

echo "PHP-Debugger: not specified - default is xdebug"
phpModuleRemove "blackfire"

fi
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
- include: bootstrap/php-module.yml
- include: bootstrap/php-module.opcache.yml
- include: bootstrap/php-module.xdebug.yml
- include: bootstrap/php-module.blackfire.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,63 +1,56 @@
#!/usr/bin/env bash
#
# Debugger switch
#

function phpModuleEnable() {
for PHP_FILE in $*; do
if [[ -f "$PHP_FILE" ]]; then
pysed -r '^[; ]*((zend_)?(extension=.*))$' '\1' "$PHP_FILE" --write
fi
done
}
PHP_CONF_PATHS="
/etc/php5/conf.d
/etc/php7/conf.d
/etc/php.d
/etc/php5/mods-available
/etc/php5/cli/conf.d
/etc/php5/cli/conf.d
/etc/php5/fpm/conf.d
/etc/php5/fpm/conf.d
/etc/php/7.0/mods-available
/etc/php/7.0/cli/conf.d
/etc/php/7.0/fpm/conf.d"

function phpModuleRemove() {
if [ "$#" -ne 1 ]; then
echo "You must specify the name of the PHP module which you want to disable"
exit 1
fi

function phpModuleDisable() {
for PHP_FILE in $*; do
if [[ -f "$PHP_FILE" ]]; then
pysed -r '^[; ]*((zend_)?(extension=.*))$' ';\1' "$PHP_FILE" --write
fi
echo " - Removing PHP module ${1}"
for CONF_PATH in $PHP_CONF_PATHS; do
rm -f "${CONF_PATH}"/*"${1}".ini
done
}

PHP_XDEBUG_FILES="
/etc/php5/conf.d/xdebug.ini
/etc/php7/conf.d/xdebug.ini
/etc/php.d/xdebug.ini
/etc/php5/mods-available/xdebug.ini
/etc/php5/cli/conf.d/20-xdebug.ini
/etc/php5/cli/conf.d/xdebug.ini
/etc/php5/fpm/conf.d/20-xdebug.ini
/etc/php5/fpm/conf.d/xdebug.ini
/etc/php/7.0/mods-available/xdebug.ini
/etc/php/7.0/cli/conf.d/20-xdebug.ini
/etc/php/7.0/fpm/conf.d/20-xdebug.ini"

PHP_BLACKFIRE_FILES="
/etc/php.d/zz-blackfire.ini
/etc/php5/conf.d/90-blackfire.ini
/etc/php5/conf.d/zz-blackfire.ini
/etc/php5/cli/conf.d/90-blackfire.ini
/etc/php5/cli/conf.d/zz-blackfire.ini
/etc/php5/fpm/conf.d/90-blackfire.ini
/etc/php5/fpm/conf.d/zz-blackfire.ini
/etc/php/7.0/cli/conf.d/90-blackfire.ini
/etc/php/7.0/fpm/conf.d/90-blackfire.ini"

if [[ -n "${PHP_DEBUGGER+x}" ]]; then
case "$PHP_DEBUGGER" in
xdebug)
echo "PHP-Debugger: Xdebug enabled"
phpModuleRemove "blackfire"
;;

blackfire)
echo "PHP-Debugger: Blackfire enabled"
phpModuleEnable $PHP_BLACKFIRE_FILES
phpModuleDisable $PHP_XDEBUG_FILES
phpModuleRemove "xdebug"
;;

none)
echo "PHP-Debugger: none"
phpModuleDisable $PHP_BLACKFIRE_FILES
phpModuleDisable $PHP_XDEBUG_FILES
phpModuleRemove "blackfire"
phpModuleRemove "xdebug"
;;
esac

else

echo "PHP-Debugger: not specified - default is xdebug"
phpModuleRemove "blackfire"

fi
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
- include: bootstrap/php-module.yml
- include: bootstrap/php-module.opcache.yml
- include: bootstrap/php-module.xdebug.yml
- include: bootstrap/php-module.blackfire.yml

This file was deleted.

Loading

0 comments on commit b6e1d45

Please sign in to comment.