I'm unable to get the Daphne server running. It always fails with the following error:
Traceback (most recent call last):
File "/usr/local/bin/daphne", line 8, in <module>
sys.exit(CommandLineInterface.entrypoint())
File "/usr/local/lib/python3.8/site-packages/daphne/cli.py", line 171, in entrypoint
cls().run(sys.argv[1:])
File "/usr/local/lib/python3.8/site-packages/daphne/cli.py", line 233, in run
application = import_by_path(args.application)
File "/usr/local/lib/python3.8/site-packages/daphne/utils.py", line 12, in import_by_path
target = importlib.import_module(module_path)
File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'apps'
/home/prassel/apps/asgi.py
django_asgi_app = get_asgi_application()
application = ProtocolTypeRouter(
{
"http": django_asgi_app,
"websocket": URLRouter([path('ws/notifications/', NotificationConsumer.as_asgi())]),
}
)
I'm starting Daphne as follows from /home/prassel/docker-compose.yml
daphne:
platform: linux/amd64
build:
context: .
dockerfile: Dockerfile.daphne
command: 'sh -c "daphne -b 0.0.0.0 -p 8000 apps.asgi:application"'
restart: always
working_dir: /home/prassel
Dockerfile.daphne
FROM python:3.8-buster
ENV PYTHONUNBUFFERED 1
ARG REQUIREMENTS_FILE
WORKDIR /home/prassel/
RUN pip install daphne