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.
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
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 |
$ docker-compose run app manage startapp myapp
$ docker-compose run app manage createsuperuser
Useful awesome list to learn more about all the different components used in this repository.