This project is a chat application based on the following tech stack1:
- Docker
- Django 3
- asgi2
- python-socketio
- djoser
- React
- Socket.IO
- Install Docker
- Clone the repo
- Add
.env
in./django
with contentPOSTGRES_DB=postgres POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_HOST=postgres POSTGRES_SSL_MODE=off SECRET_KEY=q$w!oi*7)x$=c#s(9+h@2prnbas$rsy-eh(#xm5fkd(vq3%^7o EMAIL_HOST={your-email-host} EMAIL_HOST_USER={your-email-host-user} EMAIL_HOST_PASSWORD={your-email-host-password} DOMAIN=localhost:3000 SITE_NAME=socketio
- Add
.env
in./postgres
with contentPOSTGRES_DB=postgres POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_HOST=postgres POSTGRES_SSL_MODE=off
- Add folders
./django/storage/static
and./django/storage/media
that will contain Django's static & media files - Open terminal at root level of the repo, and run
(root) ➜ docker-compose up
- Open the browser at http://localhost:8000/
An additional fabfile.py
module has been added to allow certain operations with Docker containers (e.g., ssh inside a container). To use it, you need to:
- Install Fabric3
- Open terminal at root level of the repo, and run one of the commands defined in the fabfile.py module, e.g., you can ssh inside the django container by simply running:
(root) ➜ fab ssh:django
When running on Windows, be sure to setup Docker to run in Linux mode. Moreover, it can happens that git
automatically restyled the EOL (End Of Line) of bash files. To avoid this problem, run this global command
git config --global core.autocrlf input
This command avoids the EOL (End Of Line) replacement. The latter is due to git which automatically reformat the file based on the current OS. As a conseguence, Linux-style EOL are replaced with Windows-style EOL.
Serve the client from a React application
1: The example is inspired by this repo.
2: An analogous example in which wsgi is used instead of asgi is given here.