Skip to content

Commit

Permalink
Merge pull request #3 from ModestCoders/fixes-and-improvements
Browse files Browse the repository at this point in the history
Fixes and improvements
  • Loading branch information
danielozano authored Aug 24, 2018
2 parents 185b574 + 43947cd commit e5d2014
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 38 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ and this project adheres to [Semantic Version](http://semver.org/spec/v2.0.0.htm

### Removed

## [1.1] - 18-08-2018
## [1.1] - 24-08-2018
### Changed

* Use `modestcoders/unison:2.51.2` image for unison container
* Update `markoshust/magento-php` images to PHP `7.1` using tag `7.1-fpm-3`
* Update docker setup with fixes for node and integration tests
* Update dependencies and `app-volumes` configuration to avoid issues when `app-volumes` is started several times in same `docker-compose up` execution
* Execute Dockerfile run commands for `app-volumes` in only one layer as it is best practise
* Update README with `node` and `unison` commands to use `run` instead of `exec`
* Update `xdebug + phpstorm` documentation

## [1.0.1] - 15-08-2018
### Changed
Expand Down
27 changes: 10 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ There are 2 options to sync the volumes `vendor` and `generated`
This option must be used most of the times. You should only need to sync `vendor` and `generated` from time to time for debugging purposes

```
docker-compose exec unison sync -path <path_to_sync>
docker-compose run --rm unison sync -path <path_to_sync>
```

**NOTE:** `<path_to_sync>` should be `vendor` or `generated`. For faster and more specific syncs, you can include the subfolder path inside `vendor` like `sync -path vendor/<company_name>`.
Expand All @@ -109,33 +109,26 @@ docker-compose exec unison sync -path <path_to_sync>
This option is only recommended if you are implementing code in a vendor module.

```
docker-compose exec unison watch -path <path_to_sync>
docker-compose run --rm unison watch -path <path_to_sync>
```

Example: `docker-compose exec unison watch -path vendor/<company_name>/<module_name>`
Example: `docker-compose run --rm unison watch -path vendor/<company_name>/<module_name>`

### Frontend

1. Start node container
1. NPM config setup (Only first time)

```
docker-compose up node
docker-compose run --rm node sh -c "cp -n package.json.sample package.json \
&& cp -n Gruntfile.js.sample Gruntfile.js \
&& npm install"
```

2. NPM config setup (Only first time)
2. Grunt watch

```
docker-compose exec node bash
cp package.json.sample package.json && cp Gruntfile.js.sample Gruntfile.js
npm install
```

3. Grunt watch

```
docker-compose exec node bash
grunt exec:<theme>
grunt watch
docker-compose run --rm node sh "grunt exec:<theme>"
docker-compose run --rm node sh "grunt watch"
```

## Xdebug
Expand Down
12 changes: 6 additions & 6 deletions config/docker/image/app-volumes/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ RUN mkdir -p /var/www/html/vendor \
/var/www/html/generated \
/var/www/html/var \
/var/www/html/pub/static \
/var/www/html/pub/media
/var/www/html/pub/media \
/var/www/html/dev/tests/integration/tmp \
&& chown -R 1000:1000 /var/www/html

RUN chown -R 1000:1000 /var/www/html/vendor \
/var/www/html/generated \
/var/www/html/var \
/var/www/html/pub/static \
/var/www/html/pub/media
# Keep container running until all other containers are created.
# This avoid issues when this container is started multiple times.
CMD sleep 30
7 changes: 7 additions & 0 deletions config/docker/image/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM modestcoders/node-php:node8-php7.1

RUN mkdir -p /home/app \
&& usermod -d /home/app -l app node \
&& chown -R app /home/app

USER app
7 changes: 7 additions & 0 deletions config/docker/image/phpfpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM markoshust/magento-php:7.1-fpm-3

USER root:root

RUN apt-get install -y procps

USER app:app
20 changes: 9 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,24 @@ services:
- app-var:/var/www/html/var
- pub-static:/var/www/html/pub/static
- pub-media:/var/www/html/pub/media
- integration-test-sandbox:/var/www/html/dev/tests/integration/tmp

app:
build: ./config/docker/image/nginx
ports:
- 80:8000
volumes: *appvolumes
depends_on:
- app-volumes
- phpfpm
- db
- unison

phpfpm:
image: markoshust/magento-php:7.1-fpm-3
build: ./config/docker/image/phpfpm
volumes: *appvolumes
environment:
PHP_IDE_CONFIG: serverName=localhost
depends_on:
- app-volumes
- db
- unison

db:
image: mysql:5.7
Expand Down Expand Up @@ -62,12 +59,12 @@ services:
privileged: true

node:
image: modestcoders/node-php:node8-php7.1
volumes: *appvolumes
environment:
- NPM_CONFIG_PREFIX=/home/node/.npm-global # To avoid permission error on npm install. It tries to save it at /var/www (root is the owner)
depends_on:
- app
build: ./config/docker/image/node
volumes: *appvolumes
environment:
- NPM_CONFIG_PREFIX=/home/app/.npm-global # To avoid permission error on npm install. It tries to save it at /var/www (root is the owner)
depends_on:
- app-volumes

volumes:
dbdata:
Expand All @@ -77,3 +74,4 @@ volumes:
app-var:
pub-static:
pub-media:
integration-test-sandbox:
Binary file added docs/img/debug_port.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/phpstorm_debug_listener.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/xdebug_helper_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/xdebug_helper_enable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 19 additions & 3 deletions docs/xdebug_phpstorm.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,40 @@
* Select `phpfpm` docker image

![interpreter_phpfpm_image](img/interpreter_phpfpm_image.png)

3. `PHPStorm > Preferences > Languages & Frameworks > PHP > DBGp Proxy`

3. `PHPStorm > Preferences > Languages & Frameworks > PHP > Debug`
* Debug Port: 9001

![debug_port](img/debug_port.png)

4. `PHPStorm > Preferences > Languages & Frameworks > PHP > Debug > DBGp Proxy`

* Host must match with the `REMOTE_HOST_IP` set on the [Xdebug configuration](xdebug.md)

![debug_dbgp](img/debug_dbgp.png)

4. `PHPStorm > Preferences > Languages & Frameworks > PHP > Servers`
5. `PHPStorm > Preferences > Languages & Frameworks > PHP > Servers`

* Name: `localhost` (Same as `PHP_IDE_CONFIG` in `docker-compose.yml`)
* Port: 8000
* Mapping: `/Users/<username>/Sites/<project> -> /var/www/html`

![debug_server_mapping](img/debug_server_mapping.png)

6. Start Listening for PHP Debug connections

**NOTE**: Be sure to activate that only after setting the right debug port. Changes in Debug port are ignored once the listener has started.

![PHPStorm Debug Listener](img/phpstorm_debug_listener.png)


7. Install and enable `Xdebug helper` plugin in Chrome

* [https://chrome.google.com/webstore/detail/xdebug-helper](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc)

![Xdebug Helper Config](img/xdebug_helper_config.png)
![Xdebug Helper Enable](img/xdebug_helper_enable.png)




Expand Down

0 comments on commit e5d2014

Please sign in to comment.