Skip to content

Commit e5d2014

Browse files
authored
Merge pull request #3 from ModestCoders/fixes-and-improvements
Fixes and improvements
2 parents 185b574 + 43947cd commit e5d2014

11 files changed

+64
-38
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ and this project adheres to [Semantic Version](http://semver.org/spec/v2.0.0.htm
1111

1212
### Removed
1313

14-
## [1.1] - 18-08-2018
14+
## [1.1] - 24-08-2018
1515
### Changed
1616

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

2025
## [1.0.1] - 15-08-2018
2126
### Changed

README.md

+10-17
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ There are 2 options to sync the volumes `vendor` and `generated`
9999
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
100100

101101
```
102-
docker-compose exec unison sync -path <path_to_sync>
102+
docker-compose run --rm unison sync -path <path_to_sync>
103103
```
104104

105105
**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>`.
@@ -109,33 +109,26 @@ docker-compose exec unison sync -path <path_to_sync>
109109
This option is only recommended if you are implementing code in a vendor module.
110110

111111
```
112-
docker-compose exec unison watch -path <path_to_sync>
112+
docker-compose run --rm unison watch -path <path_to_sync>
113113
```
114114

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

117117
### Frontend
118118

119-
1. Start node container
119+
1. NPM config setup (Only first time)
120120

121121
```
122-
docker-compose up node
122+
docker-compose run --rm node sh -c "cp -n package.json.sample package.json \
123+
&& cp -n Gruntfile.js.sample Gruntfile.js \
124+
&& npm install"
123125
```
124126

125-
2. NPM config setup (Only first time)
127+
2. Grunt watch
126128

127129
```
128-
docker-compose exec node bash
129-
cp package.json.sample package.json && cp Gruntfile.js.sample Gruntfile.js
130-
npm install
131-
```
132-
133-
3. Grunt watch
134-
135-
```
136-
docker-compose exec node bash
137-
grunt exec:<theme>
138-
grunt watch
130+
docker-compose run --rm node sh "grunt exec:<theme>"
131+
docker-compose run --rm node sh "grunt watch"
139132
```
140133

141134
## Xdebug

config/docker/image/app-volumes/Dockerfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ RUN mkdir -p /var/www/html/vendor \
44
/var/www/html/generated \
55
/var/www/html/var \
66
/var/www/html/pub/static \
7-
/var/www/html/pub/media
7+
/var/www/html/pub/media \
8+
/var/www/html/dev/tests/integration/tmp \
9+
&& chown -R 1000:1000 /var/www/html
810

9-
RUN chown -R 1000:1000 /var/www/html/vendor \
10-
/var/www/html/generated \
11-
/var/www/html/var \
12-
/var/www/html/pub/static \
13-
/var/www/html/pub/media
11+
# Keep container running until all other containers are created.
12+
# This avoid issues when this container is started multiple times.
13+
CMD sleep 30

config/docker/image/node/Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM modestcoders/node-php:node8-php7.1
2+
3+
RUN mkdir -p /home/app \
4+
&& usermod -d /home/app -l app node \
5+
&& chown -R app /home/app
6+
7+
USER app

config/docker/image/phpfpm/Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM markoshust/magento-php:7.1-fpm-3
2+
3+
USER root:root
4+
5+
RUN apt-get install -y procps
6+
7+
USER app:app

docker-compose.yml

+9-11
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,24 @@ services:
1212
- app-var:/var/www/html/var
1313
- pub-static:/var/www/html/pub/static
1414
- pub-media:/var/www/html/pub/media
15+
- integration-test-sandbox:/var/www/html/dev/tests/integration/tmp
1516

1617
app:
1718
build: ./config/docker/image/nginx
1819
ports:
1920
- 80:8000
2021
volumes: *appvolumes
2122
depends_on:
22-
- app-volumes
2323
- phpfpm
24-
- db
25-
- unison
2624

2725
phpfpm:
28-
image: markoshust/magento-php:7.1-fpm-3
26+
build: ./config/docker/image/phpfpm
2927
volumes: *appvolumes
3028
environment:
3129
PHP_IDE_CONFIG: serverName=localhost
3230
depends_on:
3331
- app-volumes
3432
- db
35-
- unison
3633

3734
db:
3835
image: mysql:5.7
@@ -62,12 +59,12 @@ services:
6259
privileged: true
6360

6461
node:
65-
image: modestcoders/node-php:node8-php7.1
66-
volumes: *appvolumes
67-
environment:
68-
- 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)
69-
depends_on:
70-
- app
62+
build: ./config/docker/image/node
63+
volumes: *appvolumes
64+
environment:
65+
- 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)
66+
depends_on:
67+
- app-volumes
7168

7269
volumes:
7370
dbdata:
@@ -77,3 +74,4 @@ volumes:
7774
app-var:
7875
pub-static:
7976
pub-media:
77+
integration-test-sandbox:

docs/img/debug_port.png

87.4 KB
Loading

docs/img/phpstorm_debug_listener.png

48.1 KB
Loading

docs/img/xdebug_helper_config.png

34.9 KB
Loading

docs/img/xdebug_helper_enable.png

47.9 KB
Loading

docs/xdebug_phpstorm.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,40 @@
1919
* Select `phpfpm` docker image
2020

2121
![interpreter_phpfpm_image](img/interpreter_phpfpm_image.png)
22-
23-
3. `PHPStorm > Preferences > Languages & Frameworks > PHP > DBGp Proxy`
22+
23+
3. `PHPStorm > Preferences > Languages & Frameworks > PHP > Debug`
24+
* Debug Port: 9001
25+
26+
![debug_port](img/debug_port.png)
27+
28+
4. `PHPStorm > Preferences > Languages & Frameworks > PHP > Debug > DBGp Proxy`
2429

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

2732
![debug_dbgp](img/debug_dbgp.png)
2833

29-
4. `PHPStorm > Preferences > Languages & Frameworks > PHP > Servers`
34+
5. `PHPStorm > Preferences > Languages & Frameworks > PHP > Servers`
3035

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

3540
![debug_server_mapping](img/debug_server_mapping.png)
41+
42+
6. Start Listening for PHP Debug connections
3643

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

46+
![PHPStorm Debug Listener](img/phpstorm_debug_listener.png)
47+
3848

49+
7. Install and enable `Xdebug helper` plugin in Chrome
50+
51+
* [https://chrome.google.com/webstore/detail/xdebug-helper](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc)
3952

53+
![Xdebug Helper Config](img/xdebug_helper_config.png)
54+
![Xdebug Helper Enable](img/xdebug_helper_enable.png)
55+
4056

4157

4258

0 commit comments

Comments
 (0)