Skip to content

Commit aedef90

Browse files
hot reloading improvements celery/html/tpl
1 parent b769410 commit aedef90

7 files changed

Lines changed: 16 additions & 2 deletions

Dockerfile.django-alpine

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ RUN export PYCURL_SSL_LIBRARY=openssl && \
6767
COPY \
6868
docker/entrypoint-celery-beat.sh \
6969
docker/entrypoint-celery-worker.sh \
70+
docker/entrypoint-celery-worker-dev.sh \
7071
docker/entrypoint-initializer.sh \
7172
docker/entrypoint-first-boot.sh \
7273
docker/entrypoint-uwsgi.sh \

Dockerfile.django-debian

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ RUN export PYCURL_SSL_LIBRARY=openssl && \
7070
COPY \
7171
docker/entrypoint-celery-beat.sh \
7272
docker/entrypoint-celery-worker.sh \
73+
docker/entrypoint-celery-worker-dev.sh \
7374
docker/entrypoint-initializer.sh \
7475
docker/entrypoint-first-boot.sh \
7576
docker/entrypoint-uwsgi.sh \

docker-compose.override.dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
DD_ADMIN_PASSWORD: "${DD_ADMIN_PASSWORD:-admin}"
1212
DD_EMAIL_URL: "smtp://mailhog:1025"
1313
celeryworker:
14+
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '-t', '30', '--', '/entrypoint-celery-worker-dev.sh']
1415
volumes:
1516
- '.:/app:z'
1617
environment:

docker-compose.override.integration_tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ services:
3838
environment:
3939
DD_DATABASE_URL: ${DD_TEST_DATABASE_URL:-postgresql://defectdojo:defectdojo@postgres:5432/test_defectdojo}
4040
celeryworker:
41+
entrypoint: ['/wait-for-it.sh', '${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432}', '-t', '30', '--', '/entrypoint-celery-worker-dev.sh']
4142
environment:
4243
DD_DATABASE_URL: ${DD_TEST_DATABASE_URL:-postgresql://defectdojo:defectdojo@postgres:5432/test_defectdojo}
4344
initializer:

docker/entrypoint-uwsgi-dev.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ if [ "${DD_DEBUG}" = "True" ]; then
2121
DD_UWSGI_NUM_OF_THREADS=1
2222
fi
2323

24+
# hot reload also on html/template changes
25+
watchmedo shell-command \
26+
--patterns="*.html;*.tpl" \
27+
--recursive \
28+
--command='touch /app/dojo/settings/settings.py' \
29+
/app/dojo &
30+
31+
2432
exec uwsgi \
2533
"--${DD_UWSGI_MODE}" "${DD_UWSGI_ENDPOINT}" \
2634
--protocol uwsgi \
@@ -33,5 +41,5 @@ exec uwsgi \
3341
--py-autoreload 1 \
3442
--buffer-size="${DD_UWSGI_BUFFER_SIZE:-8192}" \
3543
--lazy-apps \
36-
--touch-reload="/app/dojo/setting/settings.py" \
44+
--touch-reload="/app/dojo/settings/settings.py" \
3745
--logformat "${DD_UWSGI_LOGFORMAT:-$DD_UWSGI_LOGFORMAT_DEFAULT}"

readme-docs/DOCKER.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ This will run the application based on merged configurations from docker-compose
109109
* python code (uwsgi and celeryworker containers).
110110

111111
* The `--py-autoreload 1` parameter in entrypoint-uwsgi-dev.sh will make uwsgi handle python hot-reloading for the **uwsgi** container.
112-
* Hot-reloading for the **celeryworker** container is not yet implemented. When working on deduplication for example, restart the celeryworker container with:
112+
* Hot-reloading for the **celeryworker** container is implemented via `wathmedo` from the `watchdog` package.
113+
* Changes in `.html` and `.tpl` files will also trigger a roload.
113114

114115
```
115116
docker compose restart celeryworker

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ fontawesomefree==6.6.0
7676
PyYAML==6.0.2
7777
pyopenssl==25.1.0
7878
parameterized==0.9.0
79+
watchdog==6.0.0 # only needed for development, but would require some docker refactoring if we want to exclude it for production images

0 commit comments

Comments
 (0)