Search code examples
pythondockerdocker-composebazelbazel-rules

How do I use bazel run in docker-compose.yml in a way it auto detects changes and run bazel again?


I have bazel rules that builds a docker image for a web application. I also have a docker-compose file for local dev environment. When i build the docker-image using bazel "docker-compose up" starts and everything is fine(web application is working well at local).

What I would like to do is whenever i change code; bazel build should re-trigger without having to restart docker-compose. I am guessing it should be possible with some instructions on docker-compose.yml but i could not find how. Can anyone help?


Solution

  • Compose could watch your code and automatically kick off builds when something changes. Code can be reloaded automatically regardless of language. This would also make code reloading work on compiled languages if that was part of the build process!

    It could either be an option to up (docker-compose up --watch), an option in the config file specifying directories to watch/ignore, or perhaps a separate command (docker-compose watch). Its implemented here. For more context you can see the gitHub issue.