liip / django-template

Project template for Django projects
MIT License
17 stars 13 forks source link

Use more efficient reloader in backend container #83

Open simonbru opened 4 years ago

simonbru commented 4 years ago

Django's dev server uses almost no CPU time when idle with the watchman reloader. However this requires the watchman binary and pywatchman library.

The watchman binary is packaged in debian bullseye, but not the current stable release (buster). I tried copying the binary from a 3rd party image in the Dockerfile. It is ugly but it works:

COPY --from=workbenchdata/watchman-bin:latest-buster-slim /usr/bin/watchman /usr/local/bin/
RUN install -m777 -d /usr/var/run/watchman/

An alternative solution could be to use runserver_plus from django extensions with the watchdog reloader. It is less efficient (~2% of idle CPU usage on my machine), but easier to setup (we just need to add watchdog to dev requirements).