The stack is built on the tools in the ecosystem of Python below.
|Cloud||DigitalOcean||Cheap but fast|
|Server distro||Ubuntu 14.10 x64||Everything is latest|
|WSGI proxy||Gunicorn||Manage workers automatically|
|Web proxy||Nginx||Fast and easy to configure|
|Framework||Flask||Single file approach for MVC|
|Data store||MongoDB||No scheme needed and scalable|
|DevOps||Fabric||Agentless and Pythonic|
In addition, a Supervisor
running on the server provides a daemon to protect the Gunicorn-Flask process.
The MiniTwit app
The MiniTwit application is an example provided by Flask
, which is a prototype of Twitter like multiple-user social network. The original application depends on SQLite. However, the data store could be modified to fit the category of NoSQL such as Google Data Store or MongoDB. A live MintiTwit demo is hosted at http://minitwit-123.appspot.com/public
1. Install Fabric and clone the Github repo
The DevOps tool is fabric
that is simply based on SSH. The
and the staging
files are stored on Github. We should install
and download the fabfile.py on the local machine before the deployment.
sudo pip install fabric
2. Enter IP from the virtual machine
A new VM from ausually emails IP address and the root password. Then we could modify the head part of the
fabfile.py accordingly. There are quite a less expensive cloud providers for prototyping other than the costly Amazon EC2. For example, a minimal instance from DigitalOcean only costs five dollars a month. If SSH key has been uploaded, the password could be ignored.
env.hosts = ['YOUR IP ADDRESS']
3. Fire up Fabric
Now it is time to formally deploy the application. With the command below, the
fabric will first install
pip, git, nginx, gunicorn, supervisor and the latest
MongodB, and configure them sequentially. In less than 5 minutes, a Flask and MongoDB application will be ready for use. Since DigitalOcean has its own software repository for Ubuntu, and its VMs are on SSD, the deployment is even faster, which is usually finished in one minute.