docker-php-pre-commit/README.md
2024-02-29 17:44:55 +01:00

67 lines
2 KiB
Markdown

# Docker image to run pre-commit on PHP apps/libraries
Debian slim based images with common dependencies to run `pre-commit` on PHP apps/libraries:
- common PHP packages: `php-apcu php-cli php-curl php-deepcopy php-gd php-gnupg php-imagick php-intl php-json php-ldap php-mbstring php-memcache php-mysql php-pgsql php-rrd php-xdebug php-xml php-xmlrpc php-yaml php-zip php-gmp`
- common PHP tools: `composer`
- common python packages: `python3-all python3-dev python3-pip python3-venv`
- `build-essential` to allow local python package using `pip`
- `pre-commit` and `git` commands
- initialized `pre-commit` environments in `/src` according to provided `.pre-commit-config.yaml`
example file.
**Note:** Multiple tagged images are provided to allow test on the right Debian version you are
using in your production environment. Tags are named `debianX` with `XX` corresponding to the Debian
version. Currently supported Debian version:
- `debian10` (Debian Buster)
- `debian11` (Debian Bullseye)
- `debian12` (Debian Bookworm)
## Usage
To use it:
```bash
docker run \
-it --rm \
-v "$(pwd)":/src -w /src \
brenard/php-pre-commit \
pre-commit run --all-files
```
**Note:** To test your project with the provided `.pre-commit-config.yaml` file, use to following
command:
```bash
docker run \
-it --rm \
-v "$(pwd)":/src -w /src \
-v "$(pwd)/.pre-commit-config.yaml":/src/.pre-commit-config.yaml \
brenard/php-pre-commit \
pre-commit run --all-files
```
## Build
```bash
# Need to use Dockerfile+ (https://github.com/edrevo/dockerfile-plus)
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
for deb_version in 10 11 12
do
docker build -t docker.io/brenard/php-pre-commit:debian${deb_version} -f Dockerfile.debian${deb_version} .
done
docker build -t docker.io/brenard/php-pre-commit:latest -f Dockerfile.debian${deb_version} .
```
## Publish
```bash
for deb_version in 10 11 12
do
docker push docker.io/brenard/php-pre-commit:debian${deb_version}
done
docker push docker.io/brenard/php-pre-commit:latest
```