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.
On Linux
You will need inotify-tools
package:
Install inotify-tools on Linux
sudo apt-get install -y inotify-tools
Then run something like this:
Automatically build with inotifywait on Linux
while inotifywait -e modify -r .; do docker-compose build; done
On MacOS
You will need fswatch
tool:
Install fswatch on MacOS
brew install fswatch
Then:
Automatically build with fswatch on MacOS
fswatch -o . | xargs -n1 -I{} docker-compose build
Both commands will rebuild my Docker images after any file change in current directory. Use Ctrl+c
to exit from loop.