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:
- Dokkur account.
- SSH keys added to your account.
- Python version 2.7 installed locally - see the installation guides for OS X, Windows, and Linux.
- Setuptools and Pip installed locally. See the Python install guides above for installation instructions.
- Virtualenv installed locally. Accomplish this by running pip install virtualenv.
- Necessary DBMS installed locally, if running the app locally.
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:
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:
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
Once dependencies are installed, you will be ready to run your app locally.
Create a new app
Follow these steps:
- Open website, go to Personal apps (left menu bar)
- Click ⨁ button to open New App interface
- 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
- Go to Settings page, in Environmental variables section click on Edit button.
- Choose ADD NEW VARIABLE
- In the Name field write BUILDPACK_URL
- In the VALUE field put
- Save settings
Deploy your app
- Go to Settings page, copy the app git url from the Git URL section.
- Switch to Dokkur Toolbelt and execute this command:
git remote add dokkur git_urlInstead of git_url paste your app's git url.
- Push your app:
git push dokkur masterIf 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.