GithubHelp home page GithubHelp logo

elmoarmy / docker-django-webpack-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from domasx2/docker-django-webpack-starter

0.0 1.0 0.0 137 KB

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

HTML 3.19% Python 41.90% Shell 33.38% JavaScript 21.25% CSS 0.28%

docker-django-webpack-starter's Introduction

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

tests

For e2e tests, use app.testutils.SeleniumTestCase class it comes with chrome driver configure at self.driver. See apps.home.tests for an example.
See http://selenium-python.readthedocs.io/ for selenium driver api

#run tests
./bin/test.sh

# skip frontend build (eg, running tests repeatedly)
./bin/test.sh --skipbuild 


To debug tests it's possible to vnc into selenium container while its running at localhost:5900 and view the browser. Password is `secret`.

```sh
sudo apt-get install vinagre # vnc client

vinagre localhost:5900

docker-django-webpack-starter's People

Contributors

domasx2 avatar gedzis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.