Skip to content

A minimalist but comprehensive template for Docker and Django projects

License

Notifications You must be signed in to change notification settings

evozon/django-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

evozon/django-docker

A Cookiecutter template for a Django project using Docker. A description of the rationale behind this template is in this blog post.

What is included?

  • Packages for Django project and an app
  • Setup for Celery, uWSGI, debug-toolbar etc
  • Setup for testing using Pytest.
  • Reloader (container that restarts other containers when files change, for development).

Generating the project

Install cookiecutter and run:

cookiecutter gh:evozon/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).

Regenerating the project

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:evozon/django-docker
    
  • After installing cookiepatcher run:

    cookiepatcher gh:evozon/django-docker directory-of-project
    

Using the project

There will be a base image, so for an accurate image building process do this:

docker-compose build --pull base
docker-compose build

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.