Skip to content

lukin0110/docker-django-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Django Boilerplate

Minimal setup for a Django project with Docker, following the 12factor app principles. This repo contains skeleton code to get up and running with Docker & Django quickly. The image uses uWSGI to host the Django project. It's up to you to put Nginx or Apache in front in production.

This image is not intended as being a base image for a Django project. It's a boilerplate, you can copy/paste this and use it as a base to start a project. The image contains the hello Django project. Replace the word hello with the name of your project.

Usage

Download the repository:

$ git clone https://github.com/lukin0110/docker-django-boilerplate.git

Init project:

$ cd docker-django-boilerplate
$ docker-compose build

Setup database:

$ docker-compose up -d postgres
$ docker-compose run app setup_db

Launch:

$ docker-compose up app

Launch Nginx (optional):

$ docker-compose up web

Now your django app is available on http://localhost, but it's optional for development

Container commands

The image has

Run a command:

$ docker-compose run app <command>

Available commands:

Command Description
dev Start a normal Django development server
bash Start a bash shell
manage Start manage.py
setup_db Setup the initial database. Configure $POSTGRES_DB_NAME in docker-compose.yml
lint Run pylint
python Run a python command
shell Start a Django Python shell
uwsgi Run uwsgi server
help Show this message

Create a Django app

$ docker-compose run app manage startapp myapp

Create a super user

$ docker-compose run app manage createsuperuser

Awesome resources

Useful awesome list to learn more about all the different components used in this repository.

Useful links