https://github.com/lukin0110/docker-django-boilerplate
Minimal boilerplate setup for a Django project with Docker.
https://github.com/lukin0110/docker-django-boilerplate
boilerplate-template django docker nginx project-creation project-template python-3
Last synced: 4 months ago
JSON representation
Minimal boilerplate setup for a Django project with Docker.
- Host: GitHub
- URL: https://github.com/lukin0110/docker-django-boilerplate
- Owner: lukin0110
- License: apache-2.0
- Created: 2016-07-19T07:25:41.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-04-22T21:52:57.000Z (about 4 years ago)
- Last Synced: 2025-10-13T09:34:59.819Z (8 months ago)
- Topics: boilerplate-template, django, docker, nginx, project-creation, project-template, python-3
- Language: Python
- Homepage:
- Size: 42 KB
- Stars: 47
- Watchers: 4
- Forks: 15
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docker Django Boilerplate
Minimal setup for a Django project with Docker, following
[the 12factor app](https://12factor.net/) principles. This repo contains
skeleton code to get up and running with Docker & Django quickly. The
image uses [uWSGI](https://uwsgi-docs.readthedocs.io/) 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*](docs/rename.md).
## 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
```
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.
* [Docker](https://github.com/veggiemonk/awesome-docker)
* [Django](https://gitlab.com/rosarior/awesome-django)
* [Python](https://github.com/vinta/awesome-python)
* [Nginx](https://github.com/agile6v/awesome-nginx)
* [AWS](https://github.com/donnemartin/awesome-aws)
## Useful links
* [Docker Hub Python](https://hub.docker.com/_/python/)
* [Docker Hub Postgres](https://hub.docker.com/_/postgres/)
* [Docker compose Postgres environment variables](http://stackoverflow.com/questions/29580798/docker-compose-environment-variables)
* [Quickstart: Docker Compose and Django](https://docs.docker.com/compose/django/)
* [Best practices for writing Dockerfiles](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/)