Devilbox is a modern dockerized LAMP and MEAN stack for local development on Linux, macOS and Windows. It allows you to work on an unlimited number of projects without having to install any external software and without having to configure any virtual hosts.

It’s a very flexible development stack that can also be used offline. Internet is only required to initially pull docker containers. The only thing you will have to do is to create a new directory on the filesystem and your virtual host is ready to be served with your custom domain and even HTTPs with Let’s Encrypt.

The great thing about Devilbox is that it supports various frameworks, CMSs (Content Management Systems) and ecommerce solutions out of the box:

CakePHP

CodeIgnitre

CraftCMS

Drupal

Joomla

Laravel

Magento

Phalcon Photon

PrestaShop

Shopware

Symfony

TYPO3

WordPress

YiiFramework

ZEND Framework

MAMP Pro and Valet+

I’m not a full time developer and mainly need a local development environment to test out new versions, merge branches and do some tests on my local machine before pushing them to my git remote and deploying them to production. So far I’ve been using MAMP Pro and Valet+, both of which usually also work more or less out of the box with WordPress and Magento on macOS, the two main applications I’m usually working with at Openstream.

With MAMP Pro you can create separate hosts for each of your web projects. It’s compatible with macOS and Windows. Valet+ is a development environment only for macOS without Vagrant and Docker.

Devilbox

After updating Valet+ recently my setup somehow broke and I once again looked around for a Docker based development environment that would work with both WordPress and Magento. There are a couple of solutions out there, but usually they are optimized for either WordPress or Magento and require a pretty good understanding of how Docker works.

Although I have had contact with Docker a couple of times already and visited Docker meetups in Zürich here and there, it usually requires a lot of time to set up for WordPress and Magento, especially if you want to work with git project repositories and use it seamlessly with command line tools like WP-CLI and n98-magerun2. Under macOS, Docker is also known to be slow, especially when working with large code bases like Magento.

A basic Magento 2.3 install with sample data consists of over 72’000 files whereas in a basic installation of WordPress I only counted a little less than 4400 files (including .git project data). If you add WooCommerce and sample data you’re at around 5500 files, which is still only 7% of the number of files in Magento 2.

So one of the reasons why Magento is slow on Docker for macOS is the large quantity of files. Unfortunately, docker-sync is not yet implemented in Devilbox and I also read that it’s not so easy to implement. There’s an open issue for docker-sync support, but Cytopia, the Devilbox main developer, does no longer have macOS available, so he’s hoping to get others involved to develop and test this feature.

Docker Volume Caching

An other way to address this, recommended by Cytopia, is by enabling Docker volume caching. This is not as powerful as docker-sync, but it will at least mitigate the performance problem when Docker has to mount directories with large number of files and when you disable xdebug and use Redis, both Magento frontend and backend are loading not super fast, but acceptable for me personally.

In order to use volume caching, you will want to set MOUNT_OPTIONS=,cached in your .env Devilbox configuration file in order to allow caching on mounts. More details about this can be found in chapter 2.4.2 of the really great Devilbox documentation.

Avoid Permission Problems

Another important thing mentioned in chapter 2.3 of the installation docs is configuring your individual UID and GID. I somehow missed that initially and spent too much time trying to figure out why I had permission problems.

Let’s Encrypt

SSL certificates are generated automatically and there is almost nothing to do from your side other than importing the Certificate Authority into your browser or keychain. After you installed Devilbox, configured your .env file according to the documentation and your personal requirements respectively, you can go to the Devilbox intranet page located at https://localhost, you will see a privacy error message.

The only thing you need to do to fix this is to import the Certificate Authority as explained in chapter 2. Setup valid HTTPS. Some of the Chrome screenshots confused my a little, so I simply added the Certificate Authority located in the ca directory with the following command from the Devilbox root directory which in my case is located in /Users/Nick/Devilbox:

sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/Devilbox/ca/devilbox-ca.crt

To verify the import, you can open your Keychain Access with Launchpad or Spotlight and then should see something like this if you filter for devilbox:

Keychain Access macOS Mojave

If you now go to https://localhost the privacy error should be gone.

Apache or Nginx?

For Magento we always use Nginx as a web server in production, so I also configured Devilbox to use Nginx, but the web-based Magento installer wouldn’t work with Nginx. To work my way around this, I used the command line to run the installer, but still experienced problems after successfully installing Magento 2.3, so I decided to give Apache a try and found that with Apache even the web-based installer works, as well as static files very created correctly in pub/static whereas with Nginx this did not work.

Devilbox Intranet or Dashboard at https://localhost

This is not ideal, as the whole idea of Docker is to use not only the same packages for the web server, database server, PHP, etc. locally, but also to use the same package versions, in order to avoid unexpected problems when deploying to production.

There’s still a recent open issue regarding Nginx and Magento 2, so hopefully this will be fixed any time soon. Or even better, head over to Github and provide more feedback for Cytopia to speed up fixing this bug or fix it yourself.

Conclusion

Devilbox is a free open source project, so it would be presumptuous to expect anything, but from what I’ve seen so far, Cytopia is an amazingly dedicated person for sharing Devilbox with the developer community.

Let me know what you think of Devilbox in case you also will give it a try or have been already using it. I’ve been only using it for a couple of days, but I as I wiped my Valet+ installation and even Homebrew, I will be using it from now on as my main development stack.



