Skip to content

Commit

Permalink
Add docker image and dockerized dev tools (#10)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
samizdam and n.gnato committed May 11, 2021
1 parent 068503c commit 2c7a3d5
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/linters/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ignored:
- DL3003
- DL3008
- DL3059
- DL4006
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:

strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0']
prefer: ['lowest', 'stable']
php: [ '7.1', '7.2', '7.3', '7.4', '8.0' ]
prefer: [ 'lowest', 'stable' ]

name: Test on PHP ${{ matrix.php }} with ${{ matrix.prefer }} composer prefer option
runs-on: ubuntu-latest
Expand Down Expand Up @@ -62,4 +62,4 @@ jobs:
env:
FILTER_REGEX_EXCLUDE: .*vendor.*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_PHP_PSALM: false
VALIDATE_PHP_PSALM: false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.idea/
/.phpunit.result.cache
/_coverage/
/composer.lock
/phpunit.xml
/vendor/
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM php:7.1

# Enable phpdebug
RUN apt-get update \
&& apt-get install -y --no-install-recommends libxml2-dev \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-source extract \
&& cd /usr/src/php \
&& ./configure --enable-phpdbg \
&& docker-php-source delete

# Install composer and required packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends unzip \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

WORKDIR /app
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Add dockerized commands to path
PATH := $(PATH):tools

docker-build:
docker build -t timeweb/phpstan-enum .

install:
composer install

test:
php vendor/bin/phpunit

test-coverage:
phpdbg -qrr vendor/bin/phpunit -d memory_limit=512m --coverage-html=_coverage --coverage-text
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,24 @@ And include extension.neon in your project's PHPStan config
includes:
- vendor/timeweb/phpstan-enum/extension.neon
```
## Install for Local Development
### With docker
```bash
git clone [email protected]:timeweb/phpstan-enum.git
cd phpstan-enum
make docker-build
make install
make phpunit
```

### Without docker (localy installed actual version of php, composer, etc)

```bash
git clone [email protected]:timeweb/phpstan-enum.git
cd phpstan-enum
make install
make phpunit
```
12 changes: 12 additions & 0 deletions tools/composer
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

mkdir -p "$HOME/.composer/cache/"

test -t 1 && USE_TTY="--tty"

docker run --rm --interactive ${USE_TTY} \
--user $UID:$UID \
--volume "$PWD":/app \
--volume "$HOME/.composer":/tmp/.composer \
--env COMPOSER_HOME=/tmp/.composer \
timeweb/phpstan-enum composer "$@"
8 changes: 8 additions & 0 deletions tools/php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

test -t 1 && USE_TTY="--tty"

docker run --rm --init --interactive ${USE_TTY} \
--user $UID:$UID \
--volume "$PWD:/app" \
timeweb/phpstan-enum php "$@"
8 changes: 8 additions & 0 deletions tools/phpdbg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

test -t 1 && USE_TTY="--tty"

docker run --rm --init --interactive ${USE_TTY} \
--user $UID:$UID \
--volume "$PWD:/app" \
timeweb/phpstan-enum phpdbg "$@"

0 comments on commit 2c7a3d5

Please sign in to comment.