Introduction

This tutorial will show you how to deploy your Python app in several minutes. These instructions will also give you enough information to make the most out of Dokkur.

Be sure that you already have:

  1. Dokkur account.
  2. SSH keys added to your account.
  3. Python version 2.7 installed locally - see the installation guides for OS X, Windows, and Linux.
  4. Setuptools and Pip installed locally. See the Python install guides above for installation instructions.
  5. Virtualenv installed locally. Accomplish this by running pip install virtualenv.
  6. Necessary DBMS installed locally, if running the app locally.

Set up

In this step you will install the Dokkur Toolbelt that gives you you access to the Dokkur Command Line Interface (CLI).

After installation you can use dokkur login command to log in with your email and password you set when creating Dokkur account.

Prepare the app

To deploy an app you need to have the app prepared for deployment.

If you don’t have your own Python project, you can use a template that we have already prepared for you:

$ git clone https://github.com/dokkur/python-getting-started.git
$ cd python-getting-started

You now have a functioning git repository that contains a simple application as well as a requirements.txt file, which is used by Python’s dependency manager, Pip.

If you have a Python app that you want to deploy, you need to do some preparations.

Declare app dependencies

How does Dokkur recognize an app as a Python app? The answer is by the existence of a requirements.txt file in the root directory. You can create it by running pip freeze.

It may look something like this:

dj-database-url==0.4.0
Django==1.9.2
gunicorn==19.4.5
psycopg2==2.6.1
whitenoise==2.0.6

The requirements.txt file lists the app dependencies together with their versions. When an app is deployed, Dokkur reads this file and installs the appropriate Python dependencies using the pip install -r requirements.txt command.

To do this locally, create a virtualenv for the app:

$ virtualenv venv

Then, activate the virtualenv.
If you are using Windows, run this command:

> venv\Scripts\activate.bat

If you are not using Windows, run this command:

$ source venv/bin/activate

Now run this command in your local directory to install the dependencies, preparing your system for running the app locally:

$ pip install -r requirements.txt
Downloading/unpacking Django==1.9.2 (from -r requirements.txt (line 1))
Downloading Django-1.9.2.tar.gz (6.6MB): 6.6MB downloaded
Running setup.py egg_info for package Django
...
Successfully installed dj-database-url Django gunicorn psycopg2 whitenoise
Cleaning up...

Once dependencies are installed, you will be ready to run your app locally.

Create a new app

Follow these steps:

  1. Open website, go to Personal apps (left menu bar)
  2. Click ⨁ button to open New App interface
  3. Enter the app’s name (Caution! Use latin lowercase and numbers, e.g. myapp007), choose available and convenient instances for hosting, pick Custom App template and press Create App button.

Congrats! Your app has easily been created. Now you need to deploy it. Just do it!

Add BUILDPACK_URL config var

  1. Go to Settings page, in Environmental variables section click on Edit button.
  2. Choose ADD NEW VARIABLE
  3. In the Name field write BUILDPACK_URL
  4. In the VALUE field put
    https://github.com/dokkur/buildpack-python
  5. Save settings

Deploy your app

  1. Go to Settings page, copy the app git url from the Git URL section.
  2. Switch to Dokkur Toolbelt and execute this command:

    git remote add dokkur git_url
    Instead of git_url paste your app's git url.

  3. Push your app:
    git push dokkur master
    If you want to deploy another branch, run:
    git push dokkur yourbranch:master

Hell yeah! Your app is deployed! Open yourappname.dokkurapp.com in your browser.