Shallow dive into docker-compose - a demo repository for my tech talk presenting use case of docker-compose.
This project has simple functionality for the demo purposes. It provides model Message for creating e-mail messages with receipient address in one field and text to be sent in the second.
Django admin provides three actions for the demonstration:
- send to console - displays message and recipient in the console log
- send directly to mail - sends an e-mail to the recipient directly from django (will not work in the final stage due to network separation of django app from mail sending service)
- send to mail - sends an e-mail to the recipient by adding message to the queue and handling it in the celery worker
The e-mail is not sent right away. Instead the celery task (with Rabbit queue between) is scheduled and ran by celery worker later. The worker uses django email backend setup to send the email.
- Rename
.env.example
to.env
- Run
docker-compose build
- Run
docker-compose run --rm web python manage.py migrate
- Run
docker-compose run --rm web python manage.py createsuperuser
- Run
docker-compose up
- Login to
localhost:8000/admin/
as an admin - Add new Message object
- On the Messages list select message and from a dropdown list of actions pick send to console or email. Click go to run action.
- Check email displayed in the logs
Also check .compose_stages
dir for different stages of the docker-compose development.
- Create python virtualenv for python 3.7 on your host machine
- Run
pip install -r requirements.txt
to install required libraries - Run
./manage.py migrate
to migrate database - Run
./manage.py createsuperuser
to create admin user - Run
./manage.py runserver 0.0.0.0:8000
to run server at port8000