For some time now, I have been practicing a very strict way of keeping my local development machine clean and universal.
Working as Developer Unleasher for X-Team, I am in a unique position of having to deal with several different programming languages and technologies. Very often, I switch between projects or start new ones.
For all those reasons, I like to keep my computer free of any packages or services that are required to run specific projects.
If I had all required packages and services to run those projects on my local machine, they would simply run into conflicts with each other. For example, one PHP-project will be running on PHP7, but another would still run on a lower version. Some projects are configured to be served by the Apache Web Server and some by Nginx. Same goes for Node.js and projects running on all sorts of versions from 4 to 7. Node.js requires npm. Some tool requires globally installed node packages. Some projects use yarn. Then there are ports on which services are available. Do you get my point?
For some reason, I find myself changing computers very often. I remember when I used to spend all day to replicate all the required tools I needed to get back to development after getting a new machine. Those days have long since passed.
I work on Mac machines; this is my preference. Moreover, when I get a new machine, I usually go through a few simple steps to setup my development environment.
That is it. My number one rule has been, for some time now, I do not install anything on my machine to run projects. There is always a way to use Docker to get it going, so why would I bother?
Of course, this approach requires every project I work with to be “Dockerized”. That is actually awesome, not an issue.
I found that, very often, it took me some time to find a simple solution to create a Docker wrapper for things I wanted to do. If I simply looked for “Wordpress Docker”, “Symfony Docker” or “Node.js Docker” I would not get proper results. In fact, there was always something wrong with the setup found online.
A good setup including Docker is the one that you will start with one simple command: docker-compose
up or docker-compose run...
I started creating and sharing my own Docker “bootstraps” for several different technology stacks, which had the essentials to start playing with the given technology. These have been created only for quick setups like following some online coding courses or solving some problems.
Usually, all projects I work with are “Dockerized” and easy to setup on my local machine, without the need to install any additional components.
For Wordpress projects, I created this wrapper that helped me run a simple Wordpress installation, mainly to be able to help on StackOverflow with Wordpress-related issues.
It could also be a good starting point for any Wordpress project you have in mind. It supports automated SQL backups:
jacekelgda/docker-wordpress-mariadb
For Node.js projects, I created this wrapper, which already includes Express.js, with a simple “Hello world!” example. It also has an npm package installed in the image that monitors file changes and restarts the Express.js server to show the newest results:
jacekelgda/docker-node-express
For Symfony projects that I needed to create quickly to prepare a BDD workshop, I created this simple installation, which could also serve as a base for any project. It has been constrained to work only for the development environment:
jacekelgda/docker-symfony-nginx
All of the above are ready-to-run with services that keep them alive and which expose content to your web browser.
Just recently, I have been going through excellent Egghead.io online courses for React.js, and I found myself creating this simple docker wrapper to code along with the tutorial. This wrapper uses the Webpack module bundler to generate a JavaScript bundle, which is later included in the index.html
. You can simply open it in your web browser, without the need of running a web server:
jacekelgda/docker-react-webpack
I hope this short post will inspire you to try running everything in Docker containers. The advantages are obvious: it is fast and easy.
If you would like to create your own development playgrounds to clean your local machine of project dependencies, let me give you some advice:
version: '2'
creates a network between services, which is also very handy.docker-compose run
or solutions like supervisor.README.md
step by step, to see, if it still works.Thanks!