A Cookiecutter template for a Django project using Docker. Continuation of evozon/django-docker.
What is included?
- Packages for Django project and an app
- Setup for Celery or RQ, Apache, debug-toolbar etc
- LetsEncrypt setup with Nginx and uWSGI.
- Setup for testing using Pytest.
- Reloader (container that restarts other containers when files change, for development).
- Ansible deployment playbooks (that install Docker on the target machines and run your project with Compose).
Install cookiecutter and run:
cookiecutter gh:ionelmc/cookiecutter-django-docker
You will be asked for these fields:
Template variable | Default | Description |
---|---|---|
name |
"Nameless" |
Project name, used in headings (readme, etc). |
repo_name |
"python-nameless" |
The project's root directory name. |
django_project_name |
"nameless_project" |
Django project name (a package that contains settings and root urls). |
compose_project_name |
"nmls" |
Docker Compose project name (used for the COMPOSE_PROJECT_NAME setting). A short name is suggested to avoid
typing a lot when using Docker directly (eg: docker exec nmls_web_1 ... ) |
django_app_name |
"nameless" |
Django app name. |
short_description |
"An example package [...]" |
One line description of the project (used in README.rst ). |
If you made some wrong choices during generation you can regenerate it. There are two options:
Force Cookiecutter to override the files:
cookiecutter --overwrite-if-exists --config-file=directory-of-project/.cookiecutterrc gh:ionelmc/cookiecutter-django-docker
After installing cookiepatcher run:
cookiepatcher gh:ionelmc/cookiecutter-django-docker directory-of-project
To build the project:
docker compose build --pull
This template previously had a base image but it's just too much of a hassle and layer caching work well enough to have individual images.
To start the project run:
docker compose up
The project will provide a small shim for running tests, try:
./test.sh --help
Working with the project is the usual docker compose up
and such, nothing special or unexpected.