Skip to content

drummonds/fab_support

Repository files navigation

fab_support - Simple Django Deployment

Documentation Status Updates Python 3

Making deployment of simple Django projects simple to heroku and dokku with fabric. This implement staging so as to make it trivial to test your code eg

fab build_uat

It supports a local .env file importing for storing secrets that you don't want to store in git.

See the roadmap for current development.

Stages

Stages are the different stages of development of an application. So they might go from:

test → dev → uat → production → old production

Use of staging

Different stages of a single project

I have create a fab-support.py which does the heavy lifting of creating, updating and destroying each environment. The aim is that this should be hardly any more than the use of fabric and much simpler than the use of a full featured build Salt or Ansible. This is really only if you fit one of the use cases. Like Ansible this is a simple single master deployment system, unlike Ansible this is an opinated deployment of Django applications.

Suitable use cases:

  • Simple Django to Heroku where you have at a minimum two stages eg UAT and Production.
    • Copes with Postgres database
    • Static data in AWS
  • Deployment of Pelican static website
    • Deployment to local file system for use with a file server
    • Deployment to local for a file based browser
    • Deployment to S3

In the root fabfile create a dictionary like this which documents how to deploy each stage:

from fabric.api import env

# Definition of different environments to deploy to
env['stages'] = {
    'localsite': {
        'comment': 'stage: For serving locally on this computer via mongoose. ',
        'config_file': 'local_conf.py',
        'destination': 'C:/Sites/local.drummond.info',
        'copy_method': copy_file,
        'SITEURL': 'http:https://localhost:8042',
    },
    'production': {
        'comment': 'stage: For serving on local file server',
        'destination': '//10.0.0.1/web/www.drummond.info',
        'config_file': 'local_conf.py',
        'copy_method': copy_file,
        'SITEURL': 'http:https://www.drummond.info',
},
}

Then the deployment by Pelican is pretty standardised eg build deploy and you have commands such as:

fab localsite deploy

I think it was inspired by BreytenErnsting. This is then reimplemented using the standard env environment and support in Fabric.

Django configuration

The Django configuration includes the following features:
  • deployment to Heroku
  • Celery support with aqmp
  • Log trapping support with Papertrail

Features

Runs on Windows. If it is getting to complex then it should probably be ported to Ansible or Salt.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template. Thanks Audrey