Skip to content

amircp/python-server-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boilerplate for python web development servers with debian 7.0

Provisioning with fabric/cuisine on remote hosts and vagrant boxes

Requeriments

  • Vagrant

Download vagrant: http://www.vagrantup.com/

  • Cuisine

Install cuisine:

sudo pip install cuisine

How to use

Setup provisioning
  • Add or edit cuisine/fabric scripts in provision/recipes.

  • Add or edit config files in provision/config.

  • The main provisioning function is setup_hosts in fabfile.py, you can edit this function or add more.

  • You can add more enviroments in provision/enviroments.py.

  • Edit settings.json for add staging or production hosts/private_keys. Also you can edit options for vagrant or add new options for your commands.

  • The development enviroment is only for vagrant.

  • Example of the settings.cfg:

      {
          "enviroments": {
              "development": {
                      "IP" : "192.168.13.37",
                      "USERNAME" : "vagrant",
                      "PASSWORD" : "vagrant",
                      "VAGRANT_PRIVATE_KEY_PATH": "/Users/alvarolizama/.vagrant.d/insecure_private_key",
                      "PROVISIONER_COMMAND" : "setup_host",
                      "SRC_MOUNT_DIR" : "/home/vagrant/src"
              },
              "staging": {
                      "USERNAME": "",
                      "HOSTS" : [
                      ],
                      "PRIVATE_KEY_PATH" : ""
              },
              "production": {
                      "USERNAME": "root",            
                      "HOSTS" : [
                          "192.168.13.37:22"
                      ],
                      "PRIVATE_KEY_PATH" : "/Users/alvarolizama/.ssh/work.pem"
              }
          }
      }
    
Run vagrant
  • If you need port redirect for vagrant edit the Vagrantfile.
  • Run vagrant up for exec setup_host command in vagrant box.
  • Run vagrant ssh for enter in to vagrant box.
Run other commands in enviroments
  • For run a command of the fabfile.py in vagrant just type fab development .
  • For run a command of the fabfile.py in staging just type fab staging .
  • For run a command of the fabfile.py in production just type fab production .
Test your app in vagrant
  • Put your source code in src, vagrant mount it in /home/vagrant/src.

Include recipes

  • Setup (Edit this recipe for change the default user)

    • Install VIM
    • Install nano
    • Install tmux
    • Install some util libs
    • Config tmux for vagrant user
  • Python

    • Install python and python development files
    • Install pip
    • Install virtualenvs
  • Nginx

    • Install nginx
    • Create user for apps
    • Create dir for apps and logs
  • Uwsgi

    • Install Uwsgi
  • Postgres

    • Install postgres
    • Create user
    • Create database
    • Grant permissions
  • Gitolite

    • Install gitolite
    • Create user for git
    • Config gitolite

About

A generic boilerplate for python web development servers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors