We use watchdog[watchmedo]
with our grpc services and Docker.
Install watchdog or add to your requirements.txt
file
python -m pip install watchdog[watchmedo]
Then in your docker-compose.yml
add watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/" python -- -m app
to your container where --directory
is the directory to where your app is contained inside the docker container, and python -- -m app
is the file that starts your grpc Server. In this example the file that starts the server is called app.py
:
app:
build:
context: ./app/
dockerfile: ./Dockerfile
target: app
command: watchmedo auto-restart --recursive --pattern="*.py" --directory="/usr/src/app/" python -- -m app
volumes:
- ./app/:/usr/src/app/
command: watchmedo auto-restart --recursive --pattern="*.py" --directory="/path/to/your/app" python -- -m server
– Kulak