@@ -115,6 +115,21 @@ adjustments as described by comments in the file. This includes:
115
115
116
116
### 3. Launch the Containers
117
117
118
+ TODO: SOME FOLLOWING STEPS REQUIRE docker-compose.yml FILE CHANGES AND CHANGES
119
+ INSIDE THE CONTAINERS AFTER BEING BUILT. THAT WOULD REQUIRE SPLITTING
120
+ DESCRIPTIONS OF VARNISH ETC INTO TWO SECTIONS - STEPS TO DO BEFORE STARTING THE
121
+ CONTAINERS AND STEPS TO DO AFTERWARDS.
122
+
123
+ TODO: SHOULD WE ADD A STEP DESCRIBING HOW TO SET UP A GIT REPO TO SHARE THE
124
+ docker-compose.yml SETTINGS BETWEEN USERS?
125
+
126
+ It is recommended to read through all the following steps before launching the
127
+ containers as described below. Some of the optional steps below require
128
+ changes to the ` docker-compose.yml ` file, which requires rebuilding the
129
+ containers to take effect. For example, Gulp and BrowserSync support requires
130
+ opening up another port on the web service container. It is simpler to make
131
+ these changes before starting up the containers.
132
+
118
133
Launch the containers by changing to the project directory and then running:
119
134
120
135
docker-compose up -d
192
207
193
208
** Internal Development**
194
209
210
+ TODO: THIS SECTION IS INDICATIVE OF FUTURE DIRECTION, NOT SUPPORTED YET.
211
+
195
212
This section is ONLY relevant to internal Magento developers, or external
196
213
developers wishing to submit a pull request. The following is NOT recommended
197
214
for production sites. (It may however be worth exploring by extension
@@ -246,7 +263,8 @@ The `mysql` command can now be used without arguments or selecting database.
246
263
> exit;
247
264
248
265
Set up all the Magento 2 tables with the following command (adjusting command
249
- line paramter values as desired).
266
+ line parameter values as desired). (See below for extra arguments if you wish
267
+ to use RabbitMQ as well.)
250
268
251
269
magento setup:install --db-host=db --db-name=magento2 --db-user=root --db-password=root --admin-firstname=Magento --admin-lastname=Administrator --admin-email=user@example.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 --backend-frontname=admin
252
270
@@ -321,16 +339,6 @@ It is recommended to run the sync shell script in a separat Terminal window.
321
339
322
340
./m2devbox-unison-sync.sh
323
341
324
- ### 8. Connect with a Web Browser
325
-
326
- Run the following command to determine the web server port number.
327
-
328
- docker-compose port web 80
329
-
330
- Be aware that in developer mode the slower PHP debug mode is on and missing
331
- CSS and similar files are created on demand. This means the first time you
332
- load a page you will see significantly longer load times.
333
-
334
342
### 9. Cron
335
343
336
344
Cron is disabled by default. Running cron may result in faster draining of
@@ -341,26 +349,78 @@ second cron to run)
341
349
magento cron:run
342
350
magento cron:run
343
351
344
- To enable cron permanently run the following command .
352
+ To enable cron permanently run the following shell script .
345
353
346
- cat <<EOF | crontab -
347
- * * * * * /usr/local/bin/php /var/www/magento2/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/magento2/var/log/magento.cron.log
348
- * * * * * /usr/local/bin/php /var/www/magento2/update/cron.php >> /var/www/magento2/var/log/update.cron.log
349
- * * * * * /usr/local/bin/php /var/www/magento2/bin/magento setup:cron:run >> /var/www/magento2/var/log/setup.cron.log
350
- EOF
354
+ cron-install
351
355
352
- ### 10. Configure PHP Storm (if appropriate)
356
+ ### 8. Connect with a Web Browser
357
+
358
+ Run the following command to determine the web server port number to use when
359
+ connecting to the web service container. (This can be different to the port
360
+ number used inside the container.)
361
+
362
+ docker-compose port web 80
363
+
364
+ If the response is, for example, port 8080, connect to the web server store
365
+ front using
366
+
367
+ http://localhost:8080/
368
+
369
+ Connect to the Magento Admin by appending ` /admin ` with username "admin" and
370
+ password "admin123" (from the earlier ` magento setup:install ` command)
353
371
372
+ http://localhost:8080/admin
373
+
374
+ If you are running Docker inside VirtualBox, replace "localhost" with the IP
375
+ address VirtalBox allocated to the VM Docker is running within.
376
+
377
+ Be aware that in developer mode the slower PHP debug mode is on and missing
378
+ CSS and similar files are created on demand. This means the first time you
379
+ load a page you will see significantly longer load times.
380
+
381
+ ### 10. Configure PHP Storm (if appropriate)
354
382
TODO: Script? SSH and Remote Interpreters?
355
383
356
384
### 11. Varnish Configuration
357
385
TODO
386
+
358
387
### 12. Redis Configuration
359
388
TODO
360
- ### 13. Grunt Configuration
361
- TODO
362
- ### 14. Gulp Configuration
363
- TODO
389
+
390
+ ### 13. Grunt and Gulp Configuration
391
+
392
+ Grunt and Gulp are both frontend tool chains to speed up frontend development.
393
+ They can both auto-recompile CSS files as soon as a file is written to disk.
394
+ NodeJS is preinstalled in the web service container for use by Grunt and Gulp.
395
+
396
+ To enable Grunt support, run the following commands
397
+
398
+ cd /var/www/magento2
399
+ cp Gruntfile.js.sample Gruntfile.js
400
+ cp package.json.sample package.json
401
+ npm install
402
+ grunt refresh --force
403
+
404
+ For further details, please refer to the Grunt section in the "Frontend
405
+ Developer Guide" on http://devdocs.magento/com .
406
+
407
+ Magento does not ship with default Gulp support, but there is the excellent
408
+ "frontools" community project based on Gulp. Frontools can be found at
409
+ https://github.com/SnowdogApps/magento2-frontools . Version 0.11.4 was the last
410
+ version with Less support (as supported by Magento). Frontools provides Sass
411
+ replacements for the blank theme that they now support.
412
+
413
+ If frontools is not suitable, there are numerous other articles on the web
414
+ explaining how to set up Gulp support such as
415
+ https://alankent.me/2016/01/27/gulp-et-al-in-magento-2/ . Magento provides a
416
+ ` magento dev:source-theme:deploy ` command that resolves all of the Magento file
417
+ fallback rules, allowing Gulp or other similar pipelines to be run on the
418
+ resultant directory tree.
419
+
420
+ If you wish to run BrowserSync with Gulp (https://www.browsersync.io/ ), you
421
+ will also need to edit the ` docker-compose.yml ` file to add the BrowserSync
422
+ port number to the "ports" list to expose. For this to take effect, you must
423
+ rebuild the container which will wipe all the files in the container.
364
424
365
425
# Tips and Tricks
366
426
@@ -385,24 +445,46 @@ Restart the containers later with
385
445
If you are using Unison, remember to also restart Unison for file syncing
386
446
to work.
387
447
388
- When you no longer need the container, you can kill and remove it. THIS WILL
389
- WIPE ALL FILES INSIDE THE CONTAINER, LOSING ANY CHANGES FOREVER. It will not
390
- remove the locally synchronized files under the ` shared ` directory.
448
+ ## Removing and Rebuilding Containers
449
+
450
+ When you no longer need the DevBox, you can kill and remove all of the running
451
+ containers. THIS WILL WIPE ALL FILES INSIDE THE WEB CONTAINER AND THE DATABASE,
452
+ LOSING ANY CHANGES FOREVER. It will not remove any locally synchronized files
453
+ under the ` shared ` directory.
391
454
392
455
docker-compose kill
393
456
docker-compose rm
394
457
395
458
If you decide to change the settings in ` docker-composer.yml ` after the
396
- containers have been created, you will need to remove the current containers
397
- and recreate them (including the database contents). MAKE SURE THE SOURCE CODE
398
- IS UP TO DATE UNDER THE ` shared/www ` DIRECTORY BEFORE DELETING THE CONTAINERS
399
- TO MAKE SURE YOU DO NOT ACCIDENTALLY LOSE ANY OF YOUR WORK.
459
+ containers have been created, you will need to rebuild the containers.
460
+ MAKE SURE THE SOURCE CODE IS UP TO DATE UNDER THE ` shared/www ` DIRECTORY ON
461
+ YOUR LAPTOP BEFORE REBUILDING THE CONTAINERS TO MAKE SURE YOU DO NOT
462
+ ACCIDENTALLY LOSE ANY OF YOUR WORK.
463
+
464
+ There are two strategies you can use. The first is to delete all the containers
465
+ as above and then recreate them. This will delete the database contents as
466
+ well.
400
467
401
468
docker-compose kill
402
469
docker-compose rm
403
470
# Make changes to docker-compose.yml
404
471
docker-compose up -d
405
472
473
+ If you are using Unison file syncing, when you restart Unison locally it will
474
+ copy all the code from ` shared/www ` back into the ` /var/www ` directory inside
475
+ the container. After that, ` magento setup:install ` can be run to rebuild the
476
+ database.
477
+
478
+ The second approach is to use the ` --build ` option of Docker Compose which
479
+ will only rebuild affected containers. For example, if opening up a new port
480
+ to the web service container, using ` --build ` will not remove the database
481
+ container, preserving its contents. When the ` /var/www ` directory is restored
482
+ (via Unison or Volume mounting) the database connection settings (in ` env.php ` )
483
+ will also be restored.
484
+
485
+ # Make changes to docker-compose.yml
486
+ docker-compose up -d --build
487
+
406
488
## Kitematic
407
489
408
490
If you like GUIs, you may wish to install Kitematic from the Docker site as
0 commit comments