Skip to content

paustint/django_nginx_gunicorn_pg_python3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django_nginx_gunicorn_pg_python3

Docker container skeleton for building a Python 3 django container. Make sure that docker and docker-compose are installed.

This structure produdes a skeleton docker structure for running three containers:

  1. ngnix proxy (linked to python container)
  2. Python:3.4 environment running gunicorn (linked to the postgres container)
  3. Postgres database

The name of the containers defined in the docker-compose.yaml are as follows:

  • proxy
  • web
  • db

Requirements in requirements.txt

  • Django>=1.7
  • django-environ>=0.3.0
  • django-braces>=1.4.0
  • django-crispy-forms>=1.4.0
  • django-admin-bootstrapped>=1.6.9
  • django-debug-toolbar>=1.2.1
  • django-authtools>=1.0.0
  • easy-thumbnails>=2.2
  • psycopg2
  • gunicorn

To build

docker-compose build

To run

docker-compose up

Other useful commnads:

docker-compose run web django-admin.py startproject mysite .
docker-compose run web python mysite/manage.py syncdb
docker-compose run web python mysite/manage.py makemigrations
docker-compose run web python mysite/manage.py migrate
docker-compose run web /bin/bash
docker ps
docker-compose ps
docker-compose stop

The Dockerfile can be modified to change the working directory after the project is made so that the working directory is in the actual mysite folder and the docker-compose commands will execute directly from that directory.

Your project files can also be added directly to the current working folder on your computer and the site does not have to be from scratch

Modify DB file in django settings

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'postgres',
        'USER': 'postgres',
        'HOST': 'db',
        'PORT': 5432,
    }
}

About

Docker container skeleton for building a Python 3 django container

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages