Sample docker development environment for Magento 2.1
This environment use Nginx for the webserver in its own Docker container, there is a PHP 7.0 container for Magento (build based on php-7.0-fpm official). It is also using MariaDB latest version.
The system is also using Unison for Magento folder sync to avoid performance issue on OSX
Have Unison installed on your env
brew install unison
Have FSwatch installed also to monitor file changes
brew install fswatch
- Download Magento CE from Magento Tech there is two options with or without sample data
- Unzip downloaded file in ~/magento
- Run docker-compose to launch all containers
docker-compose up
alternatively you can use
docker-compose up --build
to rebuild your images if needed (new option/extension for PHP for example)
- Now sync your magento folder using Unison
~/magento> unison . socket://localhost:5000/ -auto -batch
This will take time on first sync, but then only the changed files will be sync again
- Go to Magento Setup follow instruction. Database Information are (host:db, Login/password:magento). For the admin URL I strongly suggest to force admin only instead of having random ID in the name.
- After setup is done don't forget to change rights on the Magento folder one more time
~/magento> chmod -R a+rwx *
- Every time you chnage your Magento file you need to rerun the Unison command to avoid this you can use fswatch
~/magento>fswatch -o . | xargs -n1 -I{} unison . socket://localhost:5000/ -auto -batch