Skip to content

starter project for django w. webpack using docker for dev environment

Notifications You must be signed in to change notification settings

Producters/docker-django-webpack-starter

 
 

Repository files navigation

docker-django-webpack-starter

This is a starter project for a django app with webpack built frontend that uses docker for dev enironment.
Docker and docker-compose is all you need to develop, build & deploy, run development or production mode with a single command.

stack

python 3.5
node 5.10
Postgres 9.5
Django 1.9.2
Webpack
Stylus
Nginx
Gunicorn

get started

Get latest docker & docker-compose:
https://www.docker.com/
https://docs.docker.com/compose/

Pull seed to your project:

git init
git remote add starter https://github.com/domasx2/docker-django-webpack-starter.git
git pull starter master

Start dev server:

./bin/develop.sh

Wait for docker to set up container, then open http://localhost:8000

production mode

# build production images, create db backup & start
./bin/deploy.sh

# stop server
./bin/stop_production.sh

# start srever
./bin/start_production.sh

In prod mode sources are added to docker image rather than mounted from host. Nginx serves static files, proxy pass to gunicorn for django app. Logs in logs dir.

enable ssl

Copy your .key and .crt files to nginx/ssl and run ./bin/deploy.sh.

install dependencies

# frontend
./bin/npm.sh install [package] --save-dev

# backend
./bin/pipinstall.sh [pacakge] #will also add entry to backend/requirements.txt

backup & restore database

# create a backup in backups dir
./bin/backup.sh 

# restore from a backup in backups dir (server must be stopped)
./bin/restore.sh backups/somebackup.bak

run django management commands

#dev mode
./bin/django.sh [command]

#create migration
./bin/django.sh makemigrations myapp

#prod mode
./bin/django_prod.sh [command]

#start django shell in prod mode
./bin/django_prod.sh shell

layout

bin/                          - various utility scripts

docker-compose.yml            - base docker compose config
docker-compose.overrides.yml  - development docker compose config
docker-compose.production.yml - production docker compose config

frontend/                     - frontend stuff
frontend/package.json         - npm package file with frotnend dependencies
frontend/src/js/              - javascript code
frontend/src/js/index.js      - js entry point. include other js deps here
frontend/src/style/           - stylesheets       
frontend/src/style/index.styl - stylesheet entry point. include other styl files here

backend/                      - backend stuff
backend/apps/                 - django apps
backend/conf/                 - django settings files
backend/conf/settings.py      - default config
backend/conf/settings_prod.py - production config
backend/templates/            - django global templates
backend/requirements.txt      - python dependencies
backend/gunicorn.conf.py      - gunicorn conf for production
backend/media/                - user uploads

logs/                         - in prod mode app, gunicorn, nginx, postgres logs go here
nginx/                        - nginx stuff for prod mode
nginx/ssl/                    - put key & cert here if you use ssl
nginx/nginx_nossl.conf        - nginx conf if no ssl is used
nginx/nginx_ssl.conf          - nginx conf for deploy with ssl

About

starter project for django w. webpack using docker for dev environment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 39.7%
  • Shell 33.4%
  • JavaScript 23.1%
  • HTML 3.5%
  • CSS 0.3%