Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Deploy Your Django App to Anynines

DZone's Guide to

How to Deploy Your Django App to Anynines

· DevOps Zone
Free Resource

The Nexus Suite is uniquely architected for a DevOps native world and creates value early in the development pipeline, provides precise contextual controls at every phase, and accelerates DevOps innovation with automation you can trust. Read how in this ebook.

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.

Prerequisites

Configure environment

  • 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 .

--- 
applications: 
- name: anydjango 
memory: 256M 
instances: 1 
host: anydjango 
path: . 

Deployment

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)

User:  jweber@anynines.com

Org:  anynines

Space:  test

$>cf push

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.

App started

Showing health and status for app anydjango3 in org anynines / space test as jweber@anynines.com...

OK

requested state: started

instances: 1/1

usage: 256M x 1 instances

urls: anydjango3.de.a9sapp.eu

state  since  cpu  memory  disk

#0  running  2014-09-08 02:49:05 PM  0.0%  31.4M of 256M  174.2M of 1G

The DevOps Zone is brought to you in partnership with Sonatype Nexus.  See how the Nexus platform infuses precise open source component intelligence into the DevOps pipeline early, everywhere, and at scale. Read how in this ebook

Topics:

Published at DZone with permission of Patrick Ross. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}