Skip to content

Commit 2c7a3d5

Browse files
samizdamn.gnato
and
n.gnato
authored
Add docker image and dockerized dev tools (#10)
* Add Makefile with dockerized dev tools * Add Makefile with dockerized dev tools * change composer installation: use latest version * Up php version for base docker image * Add to readme info about development installation with(-out) docker * Review fixes: - quotes around phpunit args - use php 7.1 for image - remove unused volumes mounting for composer - clean apt-get lists Reorder RUN instuctions for best layers caching, remove unused packages. * Fix PATH addition * Fix dockerized tools * readme cs fixes * Fix dockerfile lints * Fix lint: quote paths * Disable some dockerfile lint rules * bash quotes Co-authored-by: n.gnato <[email protected]>
1 parent 068503c commit 2c7a3d5

File tree

9 files changed

+92
-3
lines changed

9 files changed

+92
-3
lines changed

.github/linters/.hadolint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ignored:
2+
- DL3003
3+
- DL3008
4+
- DL3059
5+
- DL4006

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ jobs:
77

88
strategy:
99
matrix:
10-
php: ['7.1', '7.2', '7.3', '7.4', '8.0']
11-
prefer: ['lowest', 'stable']
10+
php: [ '7.1', '7.2', '7.3', '7.4', '8.0' ]
11+
prefer: [ 'lowest', 'stable' ]
1212

1313
name: Test on PHP ${{ matrix.php }} with ${{ matrix.prefer }} composer prefer option
1414
runs-on: ubuntu-latest
@@ -62,4 +62,4 @@ jobs:
6262
env:
6363
FILTER_REGEX_EXCLUDE: .*vendor.*
6464
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65-
VALIDATE_PHP_PSALM: false
65+
VALIDATE_PHP_PSALM: false

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
/.idea/
12
/.phpunit.result.cache
3+
/_coverage/
24
/composer.lock
35
/phpunit.xml
46
/vendor/

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM php:7.1
2+
3+
# Enable phpdebug
4+
RUN apt-get update \
5+
&& apt-get install -y --no-install-recommends libxml2-dev \
6+
&& rm -rf /var/lib/apt/lists/* \
7+
&& docker-php-source extract \
8+
&& cd /usr/src/php \
9+
&& ./configure --enable-phpdbg \
10+
&& docker-php-source delete
11+
12+
# Install composer and required packages
13+
RUN apt-get update \
14+
&& apt-get install -y --no-install-recommends unzip \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
18+
19+
WORKDIR /app

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Add dockerized commands to path
2+
PATH := $(PATH):tools
3+
4+
docker-build:
5+
docker build -t timeweb/phpstan-enum .
6+
7+
install:
8+
composer install
9+
10+
test:
11+
php vendor/bin/phpunit
12+
13+
test-coverage:
14+
phpdbg -qrr vendor/bin/phpunit -d memory_limit=512m --coverage-html=_coverage --coverage-text

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,24 @@ And include extension.neon in your project's PHPStan config
2222
includes:
2323
- vendor/timeweb/phpstan-enum/extension.neon
2424
```
25+
26+
## Install for Local Development
27+
28+
### With docker
29+
30+
```bash
31+
git clone [email protected]:timeweb/phpstan-enum.git
32+
cd phpstan-enum
33+
make docker-build
34+
make install
35+
make phpunit
36+
```
37+
38+
### Without docker (localy installed actual version of php, composer, etc)
39+
40+
```bash
41+
git clone [email protected]:timeweb/phpstan-enum.git
42+
cd phpstan-enum
43+
make install
44+
make phpunit
45+
```

tools/composer

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
mkdir -p "$HOME/.composer/cache/"
4+
5+
test -t 1 && USE_TTY="--tty"
6+
7+
docker run --rm --interactive ${USE_TTY} \
8+
--user $UID:$UID \
9+
--volume "$PWD":/app \
10+
--volume "$HOME/.composer":/tmp/.composer \
11+
--env COMPOSER_HOME=/tmp/.composer \
12+
timeweb/phpstan-enum composer "$@"

tools/php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
test -t 1 && USE_TTY="--tty"
4+
5+
docker run --rm --init --interactive ${USE_TTY} \
6+
--user $UID:$UID \
7+
--volume "$PWD:/app" \
8+
timeweb/phpstan-enum php "$@"

tools/phpdbg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
test -t 1 && USE_TTY="--tty"
4+
5+
docker run --rm --init --interactive ${USE_TTY} \
6+
--user $UID:$UID \
7+
--volume "$PWD:/app" \
8+
timeweb/phpstan-enum phpdbg "$@"

0 commit comments

Comments
 (0)