Radix Django with PostgreSQL
One-minute deployment, simple but cool web-application.
It is not recommended to deploy a database to the instances, this example shows the way to handle the multi-container situation, especially, when one container(Django) strongly depends on the other container(database).
- web app(Django)
When we launch the application with
docker-composer, it is not possible to predict the finishing time.
This can be a big problem when one container has to be launched while the other container is properly running.
In this example, PostgreSQL needs more time to be launched than the Django application when it is its first launch. However, the Django application needs to be connected with a database before it starts to run.
In the dockerfile, we should run the container with some additional tactics like in
#!/bin/bash cd src python manage.py makemigrations #until it succeeds until python manage.py migrate; do sleep 2 echo "Retry!"; done python manage.py shell < init_admin.py python manage.py makemigrations app python manage.py migrate app echo "Django is ready."; python manage.py runserver 0.0.0.0:8000
Make sure you have already installed both Docker Engine and Docker Compose. You don’t need to install Python or PostgreSQL, as both are provided by Docker images.
$ docker -v Docker version 18.03.1-ce, build 9ee9f40 $ docker-compose -v docker-compose version 1.21.1, build 5a3f1a3
git clone https://github.com/thejungwon/docker-webapp-django.git cd docker-webapp-django docker-compose up
Running the tests
Break down into end to end tests
And coding style tests
- Django - Web framework
- PostgreSQL - Database
- Unsplash - External API
- Bootstrap - Front-end framework
- Jungwon Seo - Initial work - thejungwon
This project is licensed under the MIT License - see the LICENSE file for details