Automatically build after file change

I’m playing a lot with Docker lately. Building images, and then rebuilding, and then building again… It’s pretty boring. To automate this task a little I used inotify to build automatically after I changed any file. This trick could be used in many different situations.

You will need inotify-tools package:

    sudo apt-get install -y inotify-tools

Then run something like this:

while inotifywait -e modify -r .; do docker-compose build; done

This commands will rebuild my Docker images after any file change in current directory. Use Ctrl+c to exit from loop.

Leave a Reply

Your email address will not be published. Required fields are marked *