Skip to content
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

Add docker magic #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM php:7.3-cli-alpine

ENV PROJECT_ROOT="/code"

WORKDIR ${PROJECT_ROOT}
ADD . ${PROJECT_ROOT}

# Install additional packages
RUN apk update \
&& apk upgrade \
&& apk add --no-cache $PHPIZE_DEPS php7-dev bash composer

# Install XDebug
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& echo xdebug.remote_enable=1 >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo xdebug.remote_autostart=0 >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo xdebug.remote_connect_back=1 >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo xdebug.remote_port=9000 >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo xdebug.remote_log=/tmp/php7-xdebug.log >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

# Composer
RUN composer self-update
RUN composer install

ENTRYPOINT ["/code/.docker/bin/run"]
12 changes: 12 additions & 0 deletions .docker/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
if [[ $# -eq 0 ]]
then
cd /code && composer install
fi

INTERNAL_HOST_IP=$(ip route show default | awk '/default/ {print $3}')

sed -i '/remote_host=/d' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
echo "xdebug.remote_host=${INTERNAL_HOST_IP}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

$@
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,30 @@ Now you can simply get `SlimApplicationFactory` class from your DI Container (or
$factory = $container->getByType(SlimApplicationFactory::class);
$factory->create()->run();
```

## Development
### Docker :heart:
Because no one likes to install or change his own environment for someone else's code, you can use Docker and run tests inside Docker.

To build and prepare the docker image, you can run the command bellow.
```bash
docker-compose build slim-nette-extension
```

You can run command bellow to run `composer install`.
```bash
docker-compose run slim-nette-extension
```

OR

If you want to run `composer update` or one of the scripts defined inside `composer.json`, you can use one of these commands bellow.
```bash
docker-compose run slim-nette-extension composer update
docker-compose run slim-nette-extension composer lint
docker-compose run slim-nette-extension composer phpcs
docker-compose run slim-nette-extension composer phpcbf
docker-compose run slim-nette-extension composer phpstan
docker-compose run slim-nette-extension composer tests
docker-compose run slim-nette-extension composer tests-debug
```
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"phpcs": "./vendor/bin/phpcs --ignore=\"tests/temp/*\" --standard=ruleset.xml src tests",
"phpcbf": "./vendor/bin/phpcbf --standard=ruleset.xml src tests",
"phpstan": "./vendor/bin/phpstan analyse src tests",
"test": "./vendor/bin/phpunit tests"
"tests": "./vendor/bin/phpunit tests",
"tests-debug": "XDEBUG_CONFIG='idekey=PHPSTORM remote_autostart=1' PHP_IDE_CONFIG='serverName=default' ./vendor/bin/phpunit tests --stop-on-failure"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "2"
services:
slim-nette-extension:
build:
context: .
dockerfile: .docker/Dockerfile
volumes:
- .:/code