Skip to main content

fab_support - Simple Django Deployment

https://img.shields.io/pypi/v/fab_support.svg https://img.shields.io/travis/drummonds/fab_support.svg Documentation Status Updates

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://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://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

History

0.3.0 (2019-11-12)

This is actually a series of major breaking changes.

  • Changing from requirements.txt to pipenv for managing dependencies

  • Changing from predefined tasks to methods which can be used. The destination eg heroku or dokku is abstracted into the definition of the stage.

  • Implementation of dokku alongside Heroku as a deployment platform

.env to config.json

This change is inspired by zappa which has a configuration file zappa.json. Each environment has mostly the same list of environment variables (obviously with different values). A hierachical data structure is a nice way to store these.

Predefined tasks to methods

The previous methods meant that including tasks created lots of verbiage when you did fab –list In order to simplify the output I am now providing tools that need to be selected for your particular use case.

The abstraction of the destination eg heroku or dokku into the stage is meant to make it really easy to use either platforms in a mixed deployment.

Support for dokku

I have started to use dokku for lower cost. Heroku can still scale to a larger intances.

requirements.txt to pipenv

I am using pipenv quite happily and find it easier to bundle up the dependencies and is quite widely supported eg on PyCharm.

0.2.1 (2018-05-11)

  • Updating pelican commands to the parameter method of passing stage.

Note tests were failing to a non obvious cause. This was Heroku CLI needed updating to the latest version. I manually upgraded.

0.2.0 (2018-04-20)

  • Change the way environment variables are passed through.

In version 0.1 only the following variables were considered env variables:

‘DJANGO_SECRET_KEY’, ‘DJANGO_ADMIN_URL’, ‘DJANGO_AWS_ACCESS_KEY_ID’, ‘DJANGO_AWS_SECRET_ACCESS_KEY’, ‘DJANGO_AWS_STORAGE_BUCKET_NAME’, ‘DJANGO_MAILGUN_API_KEY’, ‘DJANGO_SERVER_EMAIL’, ‘MAILGUN_SENDER_DOMAIN’, ‘DJANGO_ACCOUNT_ALLOW_REGISTRATION’, ‘DJANGO_SENTRY_DSN’, ‘XERO_CONSUMER_SECRET’, ‘XERO_CONSUMER_KEY’

Now there is an ‘ENV’ list of variables that allows any variables to be passed through and also for them to renamed on the way from the file .env

0.1.0 (2018-02-04)

  • First release on PyPI.

Release files for fab-support 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fab-support 0.3.5
File Size Uploaded
fab-support-0.3.5.tar.gz 207.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fab-support 0.3.5
File Interpreter ABI Platform
fab_support-0.3.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 224.1 kB

Release files / fab-support-0.3.5.tar.gz

Download URL fab-support-0.3.5.tar.gz
Size 207.3 kB
Tags Source
SHA-256 checksum
How to use checksums
80278b0f5aca4534e65424abb4bad1c1fde78158fc5509852686bf0163be34c8
BLAKE2b-256 checksum
How to use checksums
64c0e76c7a371ecbc76d22818cee1b94df768588087e59ea34ddee064b56bafd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.8

Release files / fab_support-0.3.5-py2.py3-none-any.whl

Download URL fab_support-0.3.5-py2.py3-none-any.whl
Size 16.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
84b43a96a056e091dafe0dcc63b1e32b0a4fbc028f783500db603245b3ce176b
BLAKE2b-256 checksum
How to use checksums
854d3620ffabb27a84bb0e6122b541af3bfb753e71589e1a899382f3d63e26e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.8

Release history Release notifications | RSS feed

This release

0.3.5 This release

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page