Skip to content

Add docker image and dockerized dev tools #10

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 13 commits into from
May 11, 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: 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 "$@"