Skip to content

feat: add tag 8.0 for phpqa image #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion 7.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
35 changes: 35 additions & 0 deletions 8.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
5 changes: 5 additions & 0 deletions 8.0/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source /etc/profile

exec "$@"
34 changes: 16 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand All @@ -49,19 +49,18 @@ $ 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:

```yaml
# 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
Expand All @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions fwd-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
]
}
2 changes: 1 addition & 1 deletion kool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion template/Dockerfile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down