Initial version
This commit is contained in:
commit
6c87ff318d
12 changed files with 184 additions and 0 deletions
6
.codespellrc
Normal file
6
.codespellrc
Normal file
|
@ -0,0 +1,6 @@
|
|||
[codespell]
|
||||
ignore-words-list = equipments
|
||||
skip = ./.*,*.csv,*.json,*.ini,*.subject,*.txt,*.html,*.log,*.conf
|
||||
quiet-level = 2
|
||||
ignore-regex = .*codespell-ignore$
|
||||
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*~
|
31
.pre-commit-config.yaml
Normal file
31
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Pre-commit hooks to run tests and ensure code is cleaned.
|
||||
# See https://pre-commit.com for more information
|
||||
---
|
||||
repos:
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.2.2
|
||||
hooks:
|
||||
- id: codespell
|
||||
args:
|
||||
#- --write-changes # Uncomment to write changes
|
||||
- --config .codespellrc
|
||||
exclude_types: [csv, json]
|
||||
|
||||
- repo: https://github.com/digitalpulp/pre-commit-php.git
|
||||
rev: 1.4.0
|
||||
hooks:
|
||||
- id: php-stan
|
||||
files: \.(php)$
|
||||
args: ["--configuration=phpstan.neon"]
|
||||
|
||||
- repo: https://github.com/adrienverge/yamllint
|
||||
rev: v1.32.0
|
||||
hooks:
|
||||
- id: yamllint
|
||||
args: ["-c", ".yamllint.yml"]
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: v2.7.1
|
||||
hooks:
|
||||
- id: prettier
|
||||
args: ["--print-width", "100"]
|
6
.yamllint.yml
Normal file
6
.yamllint.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
line-length:
|
||||
max: 100
|
8
Dockerfile.common
Normal file
8
Dockerfile.common
Normal file
|
@ -0,0 +1,8 @@
|
|||
RUN mkdir /src && \
|
||||
git config --global --add safe.directory /src
|
||||
COPY .pre-commit-config.yaml .yamllint.yml .codespellrc fake_php_project /src/
|
||||
RUN cd /src && \
|
||||
git init && \
|
||||
git add * && \
|
||||
pre-commit run --all-files && \
|
||||
rm -fr /src
|
16
Dockerfile.common.init
Normal file
16
Dockerfile.common.init
Normal file
|
@ -0,0 +1,16 @@
|
|||
ENV PYTHON_APT_PACKAGES="python3-all python3-dev python3-pip python3-venv"
|
||||
ENV PHP_APT_PACKAGES="composer 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"
|
||||
ENV DEB_APT_PACKAGES="apt-file dpkg-dev fakeroot build-essential devscripts debhelper dh-python equivs"
|
||||
ENV TOOLS_APT_PACKAGES="sed lsb-release gnupg2 curl jq git rsync gitdch wget ca-certificates openssh-client unzip"
|
||||
ENV APT_PACKAGES="$PYTHON_APT_PACKAGES $PHP_APT_PACKAGES $DEB_APT_PACKAGES $TOOLS_APT_PACKAGES"
|
||||
|
||||
ENV PIP_PACKAGES="pre-commit"
|
||||
|
||||
RUN echo "deb http://debian.zionetrix.net stable main" > /etc/apt/sources.list.d/zionetrix.list && \
|
||||
apt-get -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true update && \
|
||||
apt-get -o APT::Get::AllowUnauthenticated=true install --yes zionetrix-archive-keyring && \
|
||||
apt-get update && \
|
||||
apt-get install --no-install-recommends -y $APT_PACKAGES && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
apt-file update
|
10
Dockerfile.debian10
Normal file
10
Dockerfile.debian10
Normal file
|
@ -0,0 +1,10 @@
|
|||
# syntax = edrevo/dockerfile-plus
|
||||
|
||||
FROM debian:10-slim
|
||||
|
||||
INCLUDE+ Dockerfile.common.init
|
||||
|
||||
RUN python3 -m pip install -U pip && \
|
||||
python3 -m pip install $PIP_PACKAGES
|
||||
|
||||
INCLUDE+ Dockerfile.common
|
9
Dockerfile.debian11
Normal file
9
Dockerfile.debian11
Normal file
|
@ -0,0 +1,9 @@
|
|||
# syntax = edrevo/dockerfile-plus
|
||||
|
||||
FROM debian:11-slim
|
||||
|
||||
INCLUDE+ Dockerfile.common.init
|
||||
|
||||
RUN python3 -m pip install $PIP_PACKAGES
|
||||
|
||||
INCLUDE+ Dockerfile.common
|
9
Dockerfile.debian12
Normal file
9
Dockerfile.debian12
Normal file
|
@ -0,0 +1,9 @@
|
|||
# syntax = edrevo/dockerfile-plus
|
||||
|
||||
FROM debian:12-slim
|
||||
|
||||
INCLUDE+ Dockerfile.common.init
|
||||
|
||||
RUN python3 -m pip install --break-system-packages $PIP_PACKAGES
|
||||
|
||||
INCLUDE+ Dockerfile.common
|
69
README.md
Normal file
69
README.md
Normal file
|
@ -0,0 +1,69 @@
|
|||
# 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:
|
||||
|
||||
- `pre-commit` and `git` commands
|
||||
- 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 Debian packages building tools: `apt-file dpkg-dev fakeroot build-essential devscripts debhelper dh-python equivs`
|
||||
- common python packages: `python3-all python3-dev python3-pip python3-venv`
|
||||
- common tools: `sed lsb-release gnupg2 curl jq rsync wget ca-certificates openssh-client unzip`
|
||||
- [gitdch](https://gitea.zionetrix.net/bn8/gitdch) tool
|
||||
- an 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
|
||||
```
|
2
fake_php_project/.gitignore
vendored
Normal file
2
fake_php_project/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
vendor
|
||||
composer.lock
|
17
fake_php_project/composer.json
Normal file
17
fake_php_project/composer.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "brenard/fake_php_project",
|
||||
"description": "Fake project",
|
||||
"type": "project",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Brenard\\FakePhpProject\\": "src/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Benjamin Renard",
|
||||
"email": "brenard@easter-eggs.com"
|
||||
}
|
||||
],
|
||||
"require": {}
|
||||
}
|
Loading…
Reference in a new issue