cookiecutter / cookiecutter-django

Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
https://cookiecutter-django.readthedocs.io
BSD 3-Clause "New" or "Revised" License
12.09k stars 2.89k forks source link

Node instance is not registering file changes with browsersync #2642

Closed Tusky closed 4 years ago

Tusky commented 4 years ago

What happened?

I've created a project using cookiecutter, didn't touch the code at all so I can preserve what should be working, but the node container is not receiving file update changes. I've tried adding :consistent to the volume as well. WSL2 + Windows 10 + Pycharm, exact cookiecutter config pasted below. Docker 2.3.0.3

What should've happened instead?

container should register file changes and refresh page.

Steps to reproduce

project_name [My Awesome Project]:
project_slug [my_awesome_project]:
description [Behold My Awesome Project!]:
author_name [Daniel Roy Greenfeld]:
domain_name [example.com]:
email [daniel-roy-greenfeld@example.com]:
version [0.1.0]:
Select open_source_license:
1 - MIT
2 - BSD
3 - GPLv3
4 - Apache Software License 2.0
5 - Not open source
Choose from 1, 2, 3, 4, 5 [1]: 5
timezone [UTC]:
windows [n]: y
use_pycharm [n]: y
use_docker [n]: y
Select postgresql_version:
1 - 11.3
2 - 10.8
3 - 9.6
4 - 9.5
5 - 9.4
Choose from 1, 2, 3, 4, 5 [1]: 1
Select js_task_runner:
1 - None
2 - Gulp
Choose from 1, 2 [1]: 2
Select cloud_provider:
1 - AWS
2 - GCP
3 - None
Choose from 1, 2, 3 [1]: 3
Select mail_service:
1 - Mailgun
2 - Amazon SES
3 - Mailjet
4 - Mandrill
5 - Postmark
6 - Sendgrid
7 - SendinBlue
8 - SparkPost
9 - Other SMTP
Choose from 1, 2, 3, 4, 5, 6, 7, 8, 9 [1]: 1
use_async [n]: y
use_drf [n]: y
custom_bootstrap_compilation [n]:
use_compressor [n]: y
use_celery [n]: y
use_mailhog [n]: y
use_sentry [n]: y
use_whitenoise [n]: y
use_heroku [n]: y
Select ci_tool:
1 - None
2 - Travis
3 - Gitlab
Choose from 1, 2, 3 [1]: 1
keep_local_envs_in_vcs [y]:
debug [n]: y
 [WARNING]: You chose not to use a cloud provider, media files won't be served in production.
 [SUCCESS]: Project initialized, keep up the good work!

cd my_awesome_project/ docker-compose -f local.yml up

Open browsersync on localhost:3000 navigate to About change about.html contents, save the file. Nothing happens.

mailhog         | [APIv1] KEEPALIVE /api/v1/events
django          | INFO:     172.22.0.9:40930 - "GET /about/ HTTP/1.1" 200 OK
django          | INFO:     172.22.0.9:40930 - "GET /about/ HTTP/1.1" 200 OK
django          | INFO:     172.22.0.9:40936 - "GET /static/css/project.css HTTP/1.1" 304 Not Modified
django          | INFO:     172.22.0.9:40938 - "GET /static/js/project.js HTTP/1.1" 304 Not Modified
django          | WARNING:  Detected file change in '['/app/my_awesome_project/templates/pages/about.html']'. Reloading...
django          | INFO 2020-06-28 13:53:50,246 main 20 139785378338624 Shutting down
django          | INFO 2020-06-28 13:53:50,346 main 20 139785378338624 Finished server process [20]
django          | INFO 2020-06-28 13:53:52,050 main 23 140265941899072 Started server process [23]
django          | INFO 2020-06-28 13:53:52,051 on 23 140265941899072 Waiting for application startup.
django          | INFO 2020-06-28 13:53:52,051 on 23 140265941899072 ASGI 'lifespan' protocol appears unsupported.
django          | INFO 2020-06-28 13:53:52,051 on 23 140265941899072 Application startup complete.
django          | WARNING:  Detected file change in '['/app/my_awesome_project/templates/pages/about.html']'. Reloading...
django          | INFO 2020-06-28 13:53:57,563 main 23 140265941899072 Shutting down
django          | INFO 2020-06-28 13:53:57,664 main 23 140265941899072 Finished server process [23]
django          | INFO 2020-06-28 13:53:59,517 main 25 139662668076864 Started server process [25]
django          | INFO 2020-06-28 13:53:59,517 on 25 139662668076864 Waiting for application startup.
django          | INFO 2020-06-28 13:53:59,518 on 25 139662668076864 ASGI 'lifespan' protocol appears unsupported.
django          | INFO 2020-06-28 13:53:59,518 on 25 139662668076864 Application startup complete.
django          | INFO:     172.22.0.9:40968 - "GET / HTTP/1.1" 200 OK
django          | INFO:     172.22.0.9:40978 - "GET /static/css/project.css HTTP/1.1" 304 Not Modified
django          | INFO:     172.22.0.9:40980 - "GET /static/js/project.js HTTP/1.1" 304 Not Modified
django          | INFO:     172.22.0.9:40988 - "GET /about/ HTTP/1.1" 200 OK
django          | INFO:     172.22.0.9:40992 - "GET /static/css/project.css HTTP/1.1" 304 Not Modified
django          | INFO:     172.22.0.9:40994 - "GET /static/js/project.js HTTP/1.1" 304 Not Modified
django          | WARNING:  Detected file change in '['/app/my_awesome_project/templates/pages/about.html']'. Reloading...
django          | INFO 2020-06-28 13:54:18,373 main 25 139662668076864 Shutting down
django          | INFO 2020-06-28 13:54:18,473 main 25 139662668076864 Finished server process [25]
django          | INFO 2020-06-28 13:54:19,995 main 29 140432872728384 Started server process [29]
django          | INFO 2020-06-28 13:54:19,996 on 29 140432872728384 Waiting for application startup.
django          | INFO 2020-06-28 13:54:19,996 on 29 140432872728384 ASGI 'lifespan' protocol appears unsupported.
django          | INFO 2020-06-28 13:54:19,996 on 29 140432872728384 Application startup complete.
mailhog         | [APIv1] KEEPALIVE /api/v1/events

Django registers the file change fine multiple times, but node/browsersync is stuck on:

> my_awesome_project@0.1.0 dev /app
> gulp
[13:52:51] Using gulpfile /app/gulpfile.js
[13:52:51] Starting 'default'...
[13:52:51] Starting 'styles'...
[13:52:51] Starting 'scripts'...
[13:52:51] Starting 'imgCompression'...
[13:52:51] gulp-imagemin: Minified 0 images
[13:52:51] Finished 'imgCompression' after 81 ms
[13:52:51] Finished 'scripts' after 177 ms
[13:52:52] Finished 'styles' after 795 ms
[13:52:52] Starting 'initBrowserSync'...
[13:52:52] Starting 'watchPaths'...
[Browsersync] Proxying: http://django:8000
[Browsersync] Access URLs:
-----------------------------------
Local: http://localhost:3000
External: http://172.22.0.9:3000
-----------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
-----------------------------------
[Browsersync] Watching files...
Tusky commented 4 years ago

~Looking into it, the issue seems to be that node itself is not registering file events through mounted windows volumes.~

~I don't think this is a cookiecutter issue. Nodemon could work but I'm not that familiar to try and implement that.~

~But if anyone comes from a google search what I did is pretty simple:~ ~I've installed nodejs on my windows machine, ran npm install, and started the gulp task in pycharm. Just like I would have without docker.~

Nevermind, fixed it!