Here’s a small helper thingy that I use to help manage multiple
docker-compose setups in production. But this will work with anything that uses Makefiles.
The idea is that I have a helpful Makefile per
docker-compose project, as kinda mentioned in this post.
In short, using a
Makefile per project allows me to mask away some long winded commands that make kick starting each environment much easier than it may otherwise have been.
The problem is that I have one Makefile per project directory, and some projects have several services. An example might be a project with:
- management console
- demo site
And so on.
Whilst it’s nice to have one command per service, it does still mean I have to log on to the server,
cd to each
dir, then run the
make start command. And in some cases this needs to be done in a particular order, so that dependant services are up before workers try to connect, and so on.
A better way is to have one
Makefile in the project root
dir, which then calls the make start command in each sub dir. Something like this:
touch /docker/myproject.com/Makefile vim /docker/myproject.com/Makefile start: make start --directory /docker/myproject.com/api && \ make start --directory /docker/myproject.com/admin && \ make start --directory /docker/myproject.com/www
This way I can now just run one command on the project root
dir, and it will take care of calling all the sub tasks that kick start the project.