Skip to content

Commit b51bb77

Browse files
author
Alan Kent
committed
Removed container names from docker-compose.yml file so native composer
project naming works. Updated sync scripts to automatically fetch binaries. Simplified Gulp discussion in README file.
1 parent 66ef6d4 commit b51bb77

File tree

4 files changed

+57
-59
lines changed

4 files changed

+57
-59
lines changed

README.md

Lines changed: 23 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ GitHub repository to the project directory.
8989
Review the `docker-compose.yml` file in a text editor, making necessary
9090
adjustments as described by comments in the file. This includes:
9191

92-
* You MUST ensure the container names are different per project to avoid
93-
conflicts. For example, the default web service container name is
94-
"proj1-m2web" and the default db service container name is "proj1-m2db".
95-
Change all occurrences of "proj1" to your project name.
96-
9792
* To enable volume mounting for the Magento source code (e.g. for Linux
9893
laptops), uncomment the volume mount line for `/var/www` in the provided
9994
`docker-compose.yml` file. For Unison (e.g. for Mac and Windows), ensure the
@@ -311,33 +306,25 @@ If you are using Unison for file syncing, you also need to start up a Unison
311306
process (and keep it running). It is generally recommended to start this up
312307
after you have installed Magento above.
313308

314-
On Windows, get a compatible version of the Unison binaries for Windows
315-
from inside the container using the following (adjust "proj1-m2web" to match
316-
your web service container name from the `docker-compose.yml` file).
317-
318-
docker cp proj1-m2web:/windows/unison.exe .
319-
docker cp proj1-m2web:/windows/unison-fsmonitor.exe .
320-
321-
Then run the supplied BAT file to launch Unison in a separate window using the
322-
START command or by double clicking the BAT file via Windows explorer. Close
323-
the window to kill Unison.
309+
On Windows, run the supplied BAT file to launch Unison in a separate window
310+
using the START command or by double clicking the BAT file via Windows
311+
explorer. This will automatically retrieve a copy of the `unison.exe` binary
312+
from the web container. Close the window to kill Unison.
324313

325314
START m2devbox-unison-sync.bat
326315

327-
Each time you log in, make sure you restart this process, but be careful to not
328-
have multiple copies running in parallel. It is not recommended to do
329-
significant work on the project without Unison running to avoid merge conflicts
330-
(rare).
331-
332-
Mac binaries and a shell script are also provided:
316+
Mac binaries and a shell script are also provided. It is recommended to run the
317+
sync shell script in a separate Terminal window so you can look at its output
318+
if you ever need to do troubleshooting.
333319

334-
docker cp proj1-m2web:/macos/unison .
335-
docker cp proj1-m2web:/macos/unison-fsmonitor .
336-
chmod +x unison unison-fsmonitor
320+
./m2devbox-unison-sync.sh
337321

338-
It is recommended to run the sync shell script in a separat Terminal window.
322+
This shell script cannot be used on Linux, only Mac OSX. Use volume mounting on
323+
Linux (not Unison).
339324

340-
./m2devbox-unison-sync.sh
325+
Each time you log in, make sure you restart Unison, but be careful to not have
326+
multiple copies running in parallel. It is not recommended to do significant
327+
work on the project without Unison running to avoid merge conflicts (rare).
341328

342329
### 9. Cron
343330

@@ -391,7 +378,8 @@ TODO
391378

392379
Grunt and Gulp are both frontend tool chains to speed up frontend development.
393380
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.
381+
NodeJS is preinstalled in the web service container for use by Grunt and Gulp,
382+
along with grunt-cli, gulp-cli, and browsersync.
395383

396384
To enable Grunt support, run the following commands
397385

@@ -400,27 +388,18 @@ To enable Grunt support, run the following commands
400388
cp package.json.sample package.json
401389
npm install
402390
grunt refresh --force
391+
grunt watch
403392

404393
For further details, please refer to the Grunt section in the "Frontend
405394
Developer Guide" on http://devdocs.magento/com.
406395

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.
396+
Magento does not ship with Gulp support, but there are numerous articles on the
397+
web explaining how to use Gulp with Magento 2, such as
398+
https://alankent.me/2016/01/27/gulp-et-al-in-magento-2/.
399+
400+
If you wish to run BrowserSync (https://www.browsersync.io/), with Gulp you
401+
need to ensure the BrowserSync ports (3000 and 3001) are left uncommented in
402+
the `docker-compose.yml` file.
424403

425404
# Tips and Tricks
426405

docker-compose.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
version: '2'
77
services:
88
web:
9-
container_name: proj1-m2web
109
restart: always
1110
image: alankent/magento2devbox-web:latest
1211
volumes:
@@ -72,7 +71,6 @@ services:
7271
- 3001
7372

7473
db:
75-
container_name: proj1-m2db
7674
restart: always
7775
image: mysql:5.6
7876

@@ -92,3 +90,19 @@ services:
9290
# container. (Not recommended.)
9391
#- "./shared/db:/var/lib/mysql"
9492

93+
# Uncomment the following lines to enable Redis support.
94+
# (Make sure the service name indentation remains exactly aligned with
95+
# the previous service names)
96+
#redis:
97+
# restart: always
98+
# image: redis:3.0.7
99+
100+
# Uncomment the following to enable ElasticSearch support.
101+
# (Make sure the service name indentation remains exactly aligned with
102+
# the previous service names)
103+
#elasticsearch:
104+
# restart: always
105+
# image: elasticsearch:2
106+
# ports:
107+
# - 9200
108+

m2devbox-unison-sync.bat

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
REM @ECHO OFF
22

3+
@SET PROJ=%COMPOSE_PROJECT_NAME%
4+
@IF [%PROJ%] == [] (
5+
REM Get current directory name.
6+
FOR %%a IN (.) DO SET PROJ=%%~nxa
7+
)
8+
39
IF NOT EXIST unison.exe (
4-
@ECHO The unison.exe binary could not be found. You can retrieve a
5-
@ECHO compatible version from the DevBox web container using:
6-
@ECHO docker cp proj1-m2web:/windows/unison.exe .
7-
@ECHO docker cp proj1-m2web:/windows/unison-fsmonitor.exe .
8-
GOTO exit
10+
REM **** Getting unison.exe binary from web container.
11+
docker cp %PROJ%_web_1:/windows/unison.exe .
12+
docker cp %PROJ%_web_1:/windows/unison-fsmonitor.exe .
913
)
1014

1115
REM Add Windows\system32 to start of path to find the right "timeout" command

m2devbox-unison-sync.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/bin/bash
22

3+
PROJ=$COMPOSE_PROJECT_NAME
4+
if [[ -n $PROJ ]]; then
5+
PROJ=$(basename $PWD)
6+
fi
7+
38
if [[ ! -f unison ]]; then
4-
echo "The unison binary could not be found. You can retrieve a"
5-
echo "compatible version from the DevBox web container using:"
6-
echo ""
7-
echo " docker cp proj1-m2web:/mac-osx/unison ."
8-
echo " docker cp proj1-m2web:/mac-osx/unison-fsmonitor ."
9-
echo " chmod +x unison unison-fsmonitor"
10-
echo ""
11-
exit 1
9+
echo "Fetching unison executable from web container."
10+
docker cp ${PROJ}_web_1:/mac-osx/unison .
11+
docker cp ${PROJ}_web_1:/mac-osx/unison-fsmonitor .
12+
chmod +x unison unison-fsmonitor
1213
fi
1314

1415
# Fetch the external Docker Unison port number

0 commit comments

Comments
 (0)