node.jsdockergulpnodemongulp-karma

How to run nodemon and different gulp tasks in a docker container


I've been trying to move my node.js dev environment to a docker container. There's just one concern I have right now. I'm currently running gulp to watch changes in my files and do a rebuild, nodemon for restarting the node server on file changes and some other gulp task ("gulp test") to run my unit tests with karma. How can I run multiple processes from a docker container so that I can easily run tests and have both gulp and nodemon running?

I'd appreciate a nudge in the right direction


Solution

  • I'd start by using a shared volume and separate containers for as many of these processes as you can. A common template seen in other docker solutions is to have a git repo watcher that keeps the data volume updated, and nginx running in a separate container hosting the content in that volume.

    For anything where you really can't separate the processes, you can use supervisord. It has a lightweight configuration to launch multiple processes, can automatically restart down processes, and handles signals from Docker to gracefully exit.