From 6be9dd81f01c0c0c903a71b08666cd9d27735c62 Mon Sep 17 00:00:00 2001 From: Thiago Braga Date: Tue, 25 May 2021 19:24:34 -0300 Subject: [PATCH] feat: add tag 8.0 for phpqa image --- 7.4/Dockerfile | 5 ++++- 8.0/Dockerfile | 35 +++++++++++++++++++++++++++++++++++ 8.0/entrypoint.sh | 5 +++++ README.md | 34 ++++++++++++++++------------------ fwd-template.json | 15 +++++++++++++++ kool.yml | 2 +- template/Dockerfile.blade.php | 4 +++- 7 files changed, 79 insertions(+), 21 deletions(-) create mode 100644 8.0/Dockerfile create mode 100644 8.0/entrypoint.sh diff --git a/7.4/Dockerfile b/7.4/Dockerfile index 2c6fe8d..9b06b2e 100644 --- a/7.4/Dockerfile +++ b/7.4/Dockerfile @@ -7,13 +7,16 @@ RUN sed -i 's/\(^export PATH=.*\)/\1:\/root\/.composer\/vendor\/bin:\/phars/' /e RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ && pecl install ast \ && echo 'extension=ast.so' >> /usr/local/etc/php/php.ini \ + && docker-php-ext-enable xdebug \ && apk del .build-deps \ && rm -rf /var/cache/apk/* /tmp/* # install QA tools RUN \ # install and set up QA tools from Composer - composer global require friendsofphp/php-cs-fixer phan/phan \ + composer global require squizlabs/php_codesniffer \ + friendsofphp/php-cs-fixer \ + phan/phan \ # download PHAR and make them executable && mkdir /phars \ && curl -Lf https://phpmd.org/static/latest/phpmd.phar -o /phars/phpmd \ diff --git a/8.0/Dockerfile b/8.0/Dockerfile new file mode 100644 index 0000000..0fdc3d6 --- /dev/null +++ b/8.0/Dockerfile @@ -0,0 +1,35 @@ +FROM kooldev/php:8.0 + +# make Composer global vendor/bin available through PATH +RUN sed -i 's/\(^export PATH=.*\)/\1:\/root\/.composer\/vendor\/bin:\/phars/' /etc/profile + +# install dependencies (ast) +RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ + && pecl install ast \ + && echo 'extension=ast.so' >> /usr/local/etc/php/php.ini \ + && docker-php-ext-enable xdebug \ + && apk del .build-deps \ + && rm -rf /var/cache/apk/* /tmp/* + +# install QA tools +RUN \ + # install and set up QA tools from Composer + composer global require squizlabs/php_codesniffer \ + friendsofphp/php-cs-fixer \ + phan/phan \ + # download PHAR and make them executable + && mkdir /phars \ + && curl -Lf https://phpmd.org/static/latest/phpmd.phar -o /phars/phpmd \ + && curl -Lf https://github.com/fabpot/local-php-security-checker/releases/download/v1.0.0/local-php-security-checker_1.0.0_linux_amd64 -o /phars/local-php-security-checker \ + && curl -Lf https://phar.phpunit.de/phpcpd.phar -o /phars/phpcpd \ + && curl -Lf https://phar.phpunit.de/phpunit-nightly.phar -o /phars/phpunit10 \ + && curl -Lf https://phar.phpunit.de/phpunit-9.5.phar -o /phars/phpunit \ + && chmod +x /phars/* \ + # post-install tools settings + && /phars/local-php-security-checker --update-cache + +ADD entrypoint.sh /kool/entrypoint.sh +RUN chmod +x /kool/entrypoint.sh + +ENTRYPOINT [ "/kool/entrypoint.sh" ] +CMD [ "composer", "--version" ] diff --git a/8.0/entrypoint.sh b/8.0/entrypoint.sh new file mode 100644 index 0000000..fd66291 --- /dev/null +++ b/8.0/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source /etc/profile + +exec "$@" diff --git a/README.md b/README.md index e877beb..afadbe4 100644 --- a/README.md +++ b/README.md @@ -2,27 +2,27 @@ ## Description -Minimal PHP QA Docker image focused on loca/CI static analysis, styling and other tools. +Minimal PHP QA Docker image focused on local/CI static analysis, styling and other tools. It's plays nicely with [kool.dev](https://github.com/kool-dev/kool) managed environments, but can fit in any other PHP use-case. -#### Tools included in the image +### Tools included in the image -**Static analysis** +#### Static analysis - Phan - static analyzer for PHP (`phan`) - PHP Mess Detector (`phpmd`) - PHP Copy/Paste Detector (`phpcpd`) -**Code Style** +#### Code Style - PHP Coding Standards Fixer (`php-cs-fixer`) -**Security** +#### Security - Local PHP Security Checker (`local-php-security-checker`) -**Testing** +#### Testing - PHPUnit 9.5 (`phpunit`) - PHPUnit 10 (`phpunit10` for cutting-edge testing) @@ -31,16 +31,16 @@ It's plays nicely with [kool.dev](https://github.com/kool-dev/kool) managed envi Just execute any QA tool available straight from a new container. Using [`kool`](https://github.com/kool-dev/kool) is the prefered way: -```console -$ cd my-laravel-project/ -$ kool docker kooldev/phpqa:7.4 phan -$ kool docker kooldev/phpqa:7.4 php-cs-fixer +```sh +cd my-laravel-project/ +kool docker kooldev/phpqa:7.4 phan +kool docker kooldev/phpqa:7.4 php-cs-fixer ``` With vanilla Docker you would need to run: -``` -$ docker run --rm --init -it -v $(pwd):/app -w /app kooldev/phpqa:7.4 +```sh +docker run --rm --init -it -v $(pwd):/app -w /app kooldev/phpqa:7.4 ``` > We strongly recommend checking out [`kool` CLI](https://github.com/kool-dev/kool) for more benefits to your Docker environemnts. @@ -49,11 +49,10 @@ $ docker run --rm --init -it -v $(pwd):/app -w /app kooldev/phpqa:7.4 The image built is [`kooldev/phpqa`](https://hub.docker.com/r/kooldev/phpqa/tags?page=1&ordering=last_updated) with tags: -### 7.4 - -- [7.4](https://github.com/kool-dev/docker-phpqa/blob/main/7.4/Dockerfile) +- [**`7.4`**](https://github.com/kool-dev/docker-phpqa/blob/main/7.4/Dockerfile) +- [**`8.0`**](https://github.com/kool-dev/docker-phpqa/blob/main/8.0/Dockerfile) -## Using kool.yml +## Using `kool.yml` Examples of what you can do in a `kool` powered environment. Add to your `kool.yml` file: @@ -61,7 +60,7 @@ Examples of what you can do in a `kool` powered environment. Add to your `kool.y # kool.yml scripts: # just an alias to the PHPQA container - phpqa: kool docker kooldev/phpqa:7.4 + phpqa: kool docker kooldev/phpqa:8.0 # using the alias to call each tool with predefined parameters # assuming your application code is located in a `app/` folder phan: kool run phpqa phan --color -p -l app -iy 5 @@ -77,7 +76,6 @@ Please feel free to use and open a PR with more QA tools you find useful to have - Ship boilerplate of CI snippets for popular engines (Github Actions, CircleCI, TravisCI). - Add more tools that we find helpful. - ### Update images with templates You should change `fwd-template.json` for configuration and `template/` folder for the actual base templates. diff --git a/fwd-template.json b/fwd-template.json index ead4007..7f05cb5 100644 --- a/fwd-template.json +++ b/fwd-template.json @@ -15,6 +15,21 @@ "path": "template/entrypoint" } ] + }, + { + "name": "8.0", + "data": { + "from": "kooldev/php:8.0" + }, + "files": [ + { + "name": "Dockerfile", + "path": "template/Dockerfile" + }, { + "name": "entrypoint.sh", + "path": "template/entrypoint" + } + ] } ] } diff --git a/kool.yml b/kool.yml index 9d84fde..8c10d49 100644 --- a/kool.yml +++ b/kool.yml @@ -6,4 +6,4 @@ scripts: # PHP 7.4 - docker build --pull -t kooldev/phpqa:7.4 7.4 # PHP 8.0 - # - docker build --pull -t kooldev/phpqa:8.0 8.0 + - docker build --pull -t kooldev/phpqa:8.0 8.0 diff --git a/template/Dockerfile.blade.php b/template/Dockerfile.blade.php index ad4de22..94420dc 100644 --- a/template/Dockerfile.blade.php +++ b/template/Dockerfile.blade.php @@ -14,7 +14,9 @@ # install QA tools RUN \ # install and set up QA tools from Composer - composer global require friendsofphp/php-cs-fixer phan/phan \ + composer global require squizlabs/php_codesniffer \ + friendsofphp/php-cs-fixer \ + phan/phan \ # download PHAR and make them executable && mkdir /phars \ && curl -Lf https://phpmd.org/static/latest/phpmd.phar -o /phars/phpmd \