Dockerizing Django with Postgres, Gunicorn, and Nginx
- Django
- PostgreSQL
- Nginx
- Gunicorn
Create docker-compose file(s) that satifies the following requirements:
- Compose up a Django app with PostgreSQL as database.
- Serve API via Nginx proxy.
- Have a service to migrate/init data from Django app.
- Have a service to test your Django app.
- Auto-reload Django app whenever a change is made from backend code.
- Persistence the database.
- Set environtment mode
- dev: running development server
- test: running unittest and test coverage
export ENV=dev|test
- Run
docker-compose run
- Load dump data
docker exec -it web ./manage.py loaddata data.json
- Collect static files
docker exec -it web ./manage.py collectstatic --noinput
- API: http://localhost:8080/api/v1
- Test coverage: http://localhost:9000