Before we can deploy a Python app to anynines we have to take care of some preparations. In this post I’d like to demonstrate the Python application deployment prerequisites and process using the example of a simple Django application. The demo application’s source code can be found on github.
At first we have to ensure that our desired Python version is specified in the runtime.txt file.
In addition we need to specify our dependencies within the requirements.txt file.
Hint: You can use the pip freeze command to show a list of installed packages
The Python buildpack uses a Procfile in the root directory of your application specifying the app’s start command
Adjust deployment manifest
Anynines uses so called manifest files to specify deployment details for applications. The example application contains an example manifest.yml file.
The most important lines within this file are the application name, the application host and the buildpack url pointing to the heroku python buildpack .
- name: anydjango
As we prepared our application environment and deployment configuration with our manifest file, we are ready to deploy the app to anynines by running the push command from our application’s root directory:
$>cf target # verify that we are in the correct organization and space
API endpoint: https://api.de.a9s.eu (API version: 2.6.0)
Using manifest file /.../anydjango/manifest.yml …
The CLI will output logs during each step of the deployment process informing of the currently executed tasks. After finishing the staging phase your application will transferred to a container and started using the Procfile’s start command.
-----> Downloaded app package (12K)
Cloning into '/tmp/buildpacks/heroku-buildpack-python'...
-----> Installing runtime (python-3.4.1)
-----> Installing dependencies with pip
Downloading/unpacking Django==1.7 (from -r requirements.txt (line 1))
At the end of the deployment process the current state of your application along with other information like the RAM usage and bound urls is displayed. You can copy the link and try your application running on anynines.
Showing health and status for app anydjango3 in org anynines / space test as email@example.com...
requested state: started
usage: 256M x 1 instances
state since cpu memory disk
#0 running 2014-09-08 02:49:05 PM 0.0% 31.4M of 256M 174.2M of 1G