#deploy django with channels to server
8 messages · Page 1 of 1 (latest)
I personally try to run all my Django projects in Docker, but it's not strictly necessary.
You likely will need a server like nginx to serve static and possibly media files, you definitely want to use nginx to upgrade the websocket connection and pass it off to channels, and you do need an ASGI server to run the app itself, for which Daphne should be a pretty good choice.
Thanks.
Am I right with that:
Let’s say I want to deploy to a cloud server like AWS, DigitalOcean or sth. I would have to dockerise my PWA and install a venv, nginx, daphne and the docker-image on the cloud server and then connect my domain to that server where the docker image is?
I usually dockerize, install gitlab-runner, add gitlab-ci code, and have it build my image straight on my VPS upon push.
If you do use docker, then you can install daphne in the python/django container, run an nginx image in docker, and skip the virtual env... Your dependencies are already isolated in the container.
I also use Traefik as an edge router... it helps make things like exposing services and Let's Encrypt certificates easier.
Finally, if you do go the Docker route... do use Docker Compose as well... it makes a ton of stuff easier.
A while ago I have written a tutorial about that, might be slightly outdated, but still valuable https://appliku.com/post/django-channels-websockets-quickstart-and-deploy
I hope I'll find time to update it soon
Learn how to create a chat application with Django channels and deploy it in production without learning about DevOps!