Giter VIP home page Giter VIP logo

django-angular-docker-seed's Introduction

bower: Dependency Status python: Dependency Status node: Dependency Status

Django + Angular seed project w. Docker

This is a seed repo intended to bootstrap django + angular project development. It uses docker for dev environment and contains a small sample application.

Requirements

Docker 1.6
Docker-compose 1.2

Stack

  • Python 3.4.3
  • PostgreSQL
  • Django
  • Jade template engine
  • Stylus css preprocessor
  • AngularJS frontend framework
  • Bootstrap3 css framework
  • Gulp based frontend build system
  • Gunicorn app server
  • Nginx web server

Installation

Docker dev environent requires latest docker, see https://docs.docker.com/installation/

Mac

  1. Install boot2docker and Docker Compose
brew install boot2docker docker-compose
  1. Initialize and start up boot2docker
boot2docker init
boot2docker start
  1. Configure your Docker host to point to your boot2docker image.
$(boot2docker shellinit)

You’ll need to run this for every terminal session that invokes the docker or docker-compose command – better export this line into your .zshrc or .bashrc.

Windows

http://www.ubuntu.com/download/desktop/

Run development server

# build images
# init database
# start django dev server & frontend builder
./bin/develop.sh

App should be up on http://localhost:8000, running django development server. You're good to go!

Run production server

# stop containers,
# create database backup
# build docker images,
# build frontend,
# collect django static files,
# run migrations,
# start development stack
./bin/deploy.sh

#stop production server
./bin/stop_production.sh

#start production server
./bin/start_production.sh

App should be up on http://localhost

TODO:
add log rotation

Configure SSL

Configure SSL on included nginx server

  1. Add your SSL key and certificat to conf/ssl
  2. Rename ssl key/cert includes in conf/nginx_ssl.conf
  3. Uncomment lines as specified by comments in docker-compose-prod.yml, conf/gunicorn.py, backend/conf/settings_prod.py

Allready running behind a SSL-enabled proxy

  1. Uncomment lines as speicifed by comments in conf/gunicorn.py, conf/nginx.conf, backend/conf/settings_prod.py

Run django management commands

# create migrations
./bin/django_admin.sh makemigrations sampleapp 

#apply migrations
./bin/django_admin.sh migrate 

#access django shell
./bin/django_admin.sh shell 

#create new admin user
./bin/django_admin.sh createsuperuser 
# etc

for production use /bin/django_admin_prod.sh

Build frontend

In case you want to build forntend separately, to host it on cdn or whatevs:

./bin/build_frontend.sh

This will build frontend & collect static files to frontend/dist

Database

# access postgress shell
./bin/psql.sh

# create a backup to backups/
./bin/db_backup.sh

# restore from backup
./bin/db_restore.sh [filename that exists in backups/]

Project layout

#the important stuff: 

bin/                     # various scripts to deploy, run, manage app
frontend/src/app         # angular application
frontend/src/stylesheets # stylus stylesheets
frontend/bower.json      # frontend dependency bower config
backend/apps             # custom backend django apps
backend/conf             # django config files
requirements.txt         # python dependencies
e2e-tests/specs          # e2e tests
logs/                    # nginx, gunicorn, app logs for production
conf/gunicorn.conf.py         # gunicorn config for production
conf/nginx.conf               # nginx config for production
backups/                      # database backups 

Unit tests

See https://docs.djangoproject.com/en/1.ū/topics/testing/overview/
Sample app includes sample tests at backend/apps/sampleapp/tests.py

# run django unit tests
./bin/run_unit_tests.sh

End to end tests

Angular's default e2e test framework protractor is used in conjunction with django test server.
Test specs are located at e2e-tests/specs/
Django e2e test config at backend/conf/settings_e2e.py

Requires java, node > 10.0 and chrome browser

To setup & run e2e tests, run:

./bin/run_e2e_tests.sh

django-angular-docker-seed's People

Contributors

domasx2 avatar gedzis avatar vyjal 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.