Improve Dockerfiles. Add common CLI debugging tools.

This commit is contained in:
Paolo Cuffiani
2015-10-26 15:13:29 +01:00
parent 87ed84f132
commit 130cd76a8c
11 changed files with 104 additions and 21 deletions
-2
View File
@@ -4,5 +4,3 @@ MAINTAINER paolo.cuffiani@chialab.it
# Install XDebug.
RUN pecl install xdebug \
&& echo "zend_extension=\"$(php-config --extension-dir)/xdebug.so\"" > $PHP_INI_DIR/conf.d/xdebug.ini
CMD ["apache2-foreground"]
-2
View File
@@ -4,5 +4,3 @@ MAINTAINER paolo.cuffiani@chialab.it
# Install XDebug.
RUN pecl install xdebug \
&& echo "zend_extension=\"$(php-config --extension-dir)/xdebug.so\"" > $PHP_INI_DIR/conf.d/xdebug.ini
CMD ["php-fpm"]
-2
View File
@@ -4,5 +4,3 @@ MAINTAINER paolo.cuffiani@chialab.it
# Install XDebug.
RUN pecl install xdebug \
&& echo "zend_extension=\"$(php-config --extension-dir)/xdebug.so\"" > $PHP_INI_DIR/conf.d/xdebug.ini
CMD ["apache2-foreground"]
-2
View File
@@ -4,5 +4,3 @@ MAINTAINER paolo.cuffiani@chialab.it
# Install XDebug.
RUN pecl install xdebug \
&& echo "zend_extension=\"$(php-config --extension-dir)/xdebug.so\"" > $PHP_INI_DIR/conf.d/xdebug.ini
CMD ["php-fpm"]
-2
View File
@@ -4,5 +4,3 @@ MAINTAINER paolo.cuffiani@chialab.it
# Install XDebug.
RUN pecl install xdebug \
&& echo "zend_extension=\"$(php-config --extension-dir)/xdebug.so\"" > $PHP_INI_DIR/conf.d/xdebug.ini
CMD ["apache2-foreground"]
-2
View File
@@ -4,5 +4,3 @@ MAINTAINER paolo.cuffiani@chialab.it
# Install XDebug.
RUN pecl install xdebug \
&& echo "zend_extension=\"$(php-config --extension-dir)/xdebug.so\"" > $PHP_INI_DIR/conf.d/xdebug.ini
CMD ["php-fpm"]
+2 -1
View File
@@ -5,4 +5,5 @@ MAINTAINER paolo.cuffiani@chialab.it
RUN pecl install xdebug \
&& echo "zend_extension=\"$(php-config --extension-dir)/xdebug.so\"" > $PHP_INI_DIR/conf.d/xdebug.ini
CMD ["php", "-a"]
# Install dev tools.
RUN composer global require --no-ansi "phpmd/phpmd" "phpunit/phpunit=4.*" "squizlabs/php_codesniffer"
+86
View File
@@ -0,0 +1,86 @@
.PHONY: pull build test
PARENT_IMAGE = chialab/php
IMAGE = chialab/php-dev
TAGS = \
latest \
5.4-apache \
5.4-fpm \
5.5-apache \
5.5-fpm \
5.6-apache \
5.6-fpm
EXTENSIONS = \
bz2 \
calendar \
iconv \
intl \
gd \
mbstring \
mcrypt \
memcached \
mysql \
mysqli \
pdo_mysql \
pdo_pgsql \
pgsql \
redis \
Xdebug \
zip
NO_PHP_7 = memcached mysql redis
pull:
@for tag in $(TAGS); do \
docker pull $(PARENT_IMAGE):$${tag}; \
done
build: pull
@for tag in $(TAGS); do \
dir=`echo "$${tag}" | sed s:-:/:`; \
if [ $$tag == 'latest' ]; then \
dir='.'; \
fi; \
docker build -t $(IMAGE):$${tag} $${dir}; \
done
test:
@echo 'Testing loaded extensions...'
@for tag in $(TAGS); do \
modules=`docker run --rm $(IMAGE):$${tag} php -m`; \
echo " - $${tag}... \c"; \
for ext in $(EXTENSIONS); do \
if ([[ $$tag != '7'* ]] || [[ "$(NO_PHP_7)" != *$$ext* ]]) && [[ $$modules != *$$ext* ]]; then \
echo "FAIL [$${ext}]"; \
exit 1; \
fi \
done; \
echo 'OK'; \
done
@echo "Checking Composer... \c";
@if [[ -z `docker run --rm $(IMAGE):latest composer --version | grep '^Composer version \d\d*\.\d\d*'` ]]; then \
echo 'FAIL'; \
exit 1; \
fi
@echo 'OK'
@echo "Checking PHP_CodeSniffer... \c";
@if [[ -z `docker run --rm $(IMAGE):latest phpcs --version | grep '^PHP_CodeSniffer version \d\d*\.\d\d*\.\d\d*'` ]]; then \
echo 'FAIL'; \
exit 1; \
fi
@echo 'OK'
@echo "Checking PHPMD... \c";
@if [[ -z `docker run --rm $(IMAGE):latest phpmd --version | grep '^PHPMD \d\d*\.\d\d*\.\d\d*'` ]]; then \
echo 'FAIL'; \
exit 1; \
fi
@echo 'OK'
@echo "Checking PHPUnit... \c";
@if [[ -z `docker run --rm $(IMAGE):latest phpunit --version | grep '^PHPUnit \d\d*\.\d\d*\.\d\d*'` ]]; then \
echo 'FAIL'; \
exit 1; \
fi
@echo 'OK'
+10 -4
View File
@@ -20,24 +20,30 @@ As you might have guessed, all tags are built on top of the corresponding tag of
The following modules and extensions have been enabled,
in addition to those you can already find in the [official PHP image](https://hub.docker.com/r/_/php/):
- `bz2`
- `calendar`
- `iconv`
- `intl`
- `gd`
- `mbstring`
- `mcrypt`
- `memcached`
- `mysql`
- `memcached` (_only PHP 5.x_)
- `mysql` (_only PHP 5.x_)
- `mysqli`
- `pdo_mysql`
- `pdo_pgsql`
- `pgsql`
- `redis`
- `redis` (_only PHP 5.x, yet_)
- `xdebug`
- `zip`
You will probably not need all this stuff. Even if having some extra extensions loaded ain't a big issue in most cases (especially in a development environment), you will very likely want to checkout this repository, remove unwanted extensions from the `Dockerfile`, and build your own image — for sometimes removing is easier than adding. 😉
## Composer
[Composer](https://getcomposer.org) is installed globally in the image tagged `latest` (that is meant for CLI usage). Please, refer to their documentation for usage hints.
Also, [PHPUnit](https://phpunit.de), [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) and [PHPMD](http://phpmd.org) have been added to the global `composer.json`, and can be invoked via command line.
## Configuring XDebug
XDebug is installed, but not yet configured.
For features like remote debugging, you will need to pass additional configurations via Apache or Nginx configuration files.
@@ -64,4 +70,4 @@ fastcgi_param PHP_VALUE "xdebug.remote_enable=1\nxdebug.remote_host=192.168.99.1
## Contributing
If you find an issue, or have a special wish not yet fulfilled, please [open an issue on GitHub](https://github.com/Chialab/docker-php/issues) providing as many details as you can (the more you are specific about your problem, the easier it is for us to fix it).
Pull requests are welcome, too! 😁 Please, check that things are working as expected before attempting a pull request, as there are no automated tests (yet) to perform such checks for you. Also, it would be nice if you could follow [best practices for writing Dockerfiles](https://docs.docker.com/articles/dockerfile_best-practices/).
Pull requests are welcome, too! 😁 Please, run `make build` and `make test` before attempting a pull request. Also, it would be nice if you could follow [best practices for writing Dockerfiles](https://docs.docker.com/articles/dockerfile_best-practices/).