@@ -14,9 +14,10 @@ control.
14
14
DevBox contains all the the software packages you need to develop a Magento
15
15
site, except for IDEs and web browsers. A local development environment
16
16
typically starts with a database container (holding MySQL) and a web server
17
- container (holding the Magento source code). Other containers can be added as
18
- required for Varnish (recommended), Redis, RabbitMQ, and ElasticSearch. All
19
- containers run Linux inside.
17
+ container (holding the Magento source code). On Mac and Windows, another
18
+ container is used for file sharing (discussed below). Other containers can be
19
+ added as required for Varnish (recommended), Redis, RabbitMQ, and
20
+ ElasticSearch. All containers run Linux inside.
20
21
21
22
Developers mainly interact with the web container. The other containers are
22
23
relatively shrink wrap.
@@ -43,16 +44,30 @@ Mac and Windows cannot directly access the file system inside the web container
43
44
works fine. By default the volume mounts are commented out in the
44
45
` docker-compose.yml ` file for improved performance.
45
46
47
+ * Docker volume mounts for Mac and Windows are slow for large projects like
48
+ Magento.
49
+
46
50
* Some frontend developer tools like Gulp and Grunt rely on file watching
47
51
"iNotify" file system events. Docker Volume mounting on Windows does not
48
52
support iNotify events at this time.
49
53
50
54
Where volume mounts are not suitable (specifically, the Magento source code
51
55
directory on Mac and Windows), DevBox syncs the local and container file
52
- systems using a program called Unison. Whenever a file in the watched local file
53
- system is changed, it is copied into the web container, and vice versa. This
54
- allows IDEs to be natively used on a laptop (or desktop) - Unison copies file
55
- changes as soon as they are written to disk into the web conatiner.
56
+ systems using a program called Unison. Whenever a file in the watched local
57
+ file system is changed, it is copied into the web container, and vice versa.
58
+ This allows IDEs to be natively used on a laptop (or desktop) - Unison copies
59
+ file changes as soon as they are written to disk into the web conatiner.
60
+
61
+ DevBox uses the "Docker Sync" project (http://docker-sync.io/ ) for file
62
+ sharing, but only uses the Unison mode of file sharing.
63
+
64
+ (Insiders secret: Unison is written in a language called OCaml. OCaml 4.01 and
65
+ 4.02 changed a serialization algorithm in a backwards incompatible way. So you
66
+ need to make sure you have Unison binaries on Windows, Mac, and Linux compiled
67
+ with the same version of OCaml. Brew + Docker-Sync + the supplied Windows
68
+ binary currently all match. If you try experimenting with other binaries,
69
+ beware the pit of despair when things start going strange for no apparent
70
+ reason!)
56
71
57
72
# Installation
58
73
@@ -70,6 +85,7 @@ ready to get up and going with DevBox.
70
85
(https://git-for-windows.github.io/ ). As well as Git, it includes SSH, an
71
86
xterm terminal emulator, and a useful collection of commonly used Linux
72
87
commands.
88
+ * On Mac, install "Brew" (https://brew.sh/ ) if you have not done so already.
73
89
74
90
## Setting Up a New Environment
75
91
@@ -91,15 +107,19 @@ this GitHub repository to the project directory.
91
107
Review the ` docker-compose.yml ` file in a text editor, making necessary
92
108
adjustments as described by comments in the file. This includes:
93
109
94
- * To enable volume mounting for the Magento source code (e.g. for Linux
95
- laptops), uncomment the volume mount line for ` /var/www ` in the provided
96
- ` docker-compose.yml ` file. For Unison (e.g. for Mac and Windows), ensure the
97
- line is commented out.
110
+ * For Mac and Windows, make sure the ` src:/var/www ` volume is uncommented and
111
+ the ` ./shared/www:/var/www ` line is commented out. Make sure the "unison"
112
+ service is also uncommented. This is required for Unison to access the
113
+ Magento source code.
114
+
115
+ * For Linux, direct file sharing can be used. Make sure the
116
+ ` ./shared/www:/var/www ` line is uncommented and the ` src:/var/www ` line is
117
+ commented out. Also comment out the "unison" service as it is not required.
98
118
99
119
* Check the port numbers. By default Docker will allocate random free port
100
- numbers. Change "80" to "8080:80" if you want the web server port to be
101
- always 8080. You cannot run different containers at the same time using
102
- the same port numbers.
120
+ numbers. Change ports such as "80" to "8080:80" if you want the web server
121
+ port to be always 8080. You cannot run different containers at the same time
122
+ using the same port numbers.
103
123
104
124
* The recommended way to create and update projects is via Composer, a PHP
105
125
package manager. Magento provides a Composer repository from which Magento
@@ -157,6 +177,11 @@ If you are running Docker in VirtualBox, you may need to edit the local `m2ssh`
157
177
and ` m2unison ` scripts to replace "localhost" with the IP address allocated by
158
178
VirtualBox.
159
179
180
+ Note: If you destroy and recreate containers, SSH may report warnings about
181
+ changes in identity and refuse to connect. Use a text editor to remove
182
+ "localhost" lines from your ` ~/.ssh/known_hosts ` file to overcome this issue
183
+ (you will then be prompted to accept new fingerprints on restart).
184
+
160
185
### 4. Install Magento
161
186
162
187
Next you need to install your Magento project inside the web container under
@@ -330,18 +355,17 @@ be added when the project was created above.
330
355
331
356
** Loading Sample Data (Optional)**
332
357
333
- To * download* the Luma sample data, you may need to provide Composer
358
+ To download the Luma sample data, you may need to provide Composer
334
359
authentication details. If you already have a ` ~/.composer/auth.json ` file you
335
360
can run
336
361
337
362
COMPOSER_AUTH=$(cat ~/.composer/auth.json) magento sampledata:deploy
338
363
339
- OTHERWISE run the following command and enter your public and private keys when
364
+ If you don't have a ` ~/.composer/auth.json ` file, just run
365
+ ` magento sampledata:deploy ` and enter your public and private keys when
340
366
prompted.
341
367
342
- magento sampledata:deploy
343
-
344
- To * load* the downloaded sample data into the database, run
368
+ To load the downloaded sample data into the database, run
345
369
346
370
magento setup:upgrade
347
371
@@ -368,6 +392,9 @@ purposes, but makes all PHP scripts slower to execute.
368
392
magento deploy:mode:set developer
369
393
xdebug-on
370
394
395
+ TODO: SEPARATE CLI AND WEB SERVER PHP CONFIGURATION, SO XDEBUG ON BY DEFAULT
396
+ FOR WEB SERVER BUT OFF FOR CLI. THEN WE CAN DROP xdebug-on AND xdebug-off.
397
+
371
398
### 8. Connect with a Web Browser
372
399
373
400
Run the following command to determine the web server port number to use when
@@ -399,25 +426,51 @@ If you are using Unison for file syncing, you also need to start up a Unison
399
426
process (and keep it running). It is generally recommended to start this up
400
427
after you have installed Magento above.
401
428
429
+ Each time you log to your laptop, make sure you restart Unison, but be careful
430
+ to not have multiple copies running in parallel. It is not recommended to do
431
+ significant work on the project without Unison running to avoid merge conflicts
432
+ (rare).
433
+
434
+ ** Mac**
435
+
436
+ TODO: VERIFY WHEN TESTING FINISHED.
437
+
438
+ On Mac, first install Unison using "brew". This installs the correct command
439
+ line version of Unison. Also install "unox" for a companion file watching
440
+ utility.
441
+
442
+ brew install unison
443
+ brew tap eugenmayer/dockersync
444
+ brew install eugenmayer/dockersync/unox
445
+
446
+ For Mac, create a "profile" file in ` ~/.unison/m2devbox-{myproj}.prf ` ({myproj}
447
+ is the current directory name) by running the following command.
448
+
449
+ ./m2unison-profile TODO: THIS SHOULD RUN SSH TO ACCEPT SSH FINGERPRINT
450
+
451
+ To perform a "once off" file synchronization, run
452
+
453
+ unison m2devbox-{myproj}
454
+
455
+ To continuously synchronize files (recommended), run
456
+
457
+ unison -repeat watch m2devbox-{myproj}
458
+
459
+ It is recommended to run Unison in a separate Terminal window so you can refer
460
+ to its output if you ever need to do troubleshooting.
461
+
462
+ ** Windows**
463
+
402
464
On Windows, run the supplied BAT file to launch Unison in a separate window
403
465
using the START command or by double clicking the BAT file via Windows file
404
466
explorer. This will automatically retrieve a copy of the ` unison.exe ` binary
405
- from the web container. Close the window to kill Unison.
467
+ from the web container. A profile is not required as the BAT file uses command
468
+ line arguments. Close the window to kill Unison.
406
469
407
470
START m2unison.bat
408
471
409
- Mac binaries and a shell script are also provided. It is recommended to run the
410
- sync shell script in a separate Terminal window so you can refer to its output
411
- if you ever need to do troubleshooting.
412
-
413
- ./m2unison.sh
414
-
415
- This shell script cannot be used on Linux, only Mac OSX. Use volume mounting on
416
- Linux (not Unison).
417
-
418
- Each time you log in, make sure you restart Unison, but be careful to not have
419
- multiple copies running in parallel. It is not recommended to do significant
420
- work on the project without Unison running to avoid merge conflicts (rare).
472
+ There is a setting at the top of the script to choose between SSH access and
473
+ direct sockets. Using a plain socket has been reported to hang occasionally.
421
474
422
475
### 10. Configure PHP Storm (Optional)
423
476
0 commit comments