Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!


All development on this project has now been shifted to GitHub (largely for Travis CI support). See

    _/_/_/                        _/
   _/    _/    _/_/    _/_/_/        _/_/_/  _/_/
  _/    _/  _/_/_/_/  _/    _/  _/  _/    _/    _/
 _/    _/  _/        _/    _/  _/  _/    _/    _/
_/_/_/      _/_/_/  _/    _/  _/  _/    _/    _/

A Fabric deployment strategy for Python web applications.

Denim has been primarily developed to support Django web applications, deployed to Debian GNU/Linux (and derivative) platforms. With tools to support nginx, supervisor, virtual env, gunicorn, pip etc.

Designed to provide a rich tool-set built on top of and working with the existing functionality provided by Fabric. Get up and running quickly with the default deployment strategy.

The default strategy

The default strategy describes a project layout and deployment structure for Django applications that lets you deploy straight away

The strategy is designed to take a freshly deployed server and provision, deploy and activate your application, using best practices.

By default your application will run as the user webapps with a /bin/false shell and write access to limited parts of the filesystem. All code is owned by root.

Folder Structure

Key Variables

Certain key variables are required to be set in the Fabric env dictionary, these should be setup in your fabfile:

The name of your project, this does not need to be Python compatible (ie you can use a dash '-').
The name of the python package being deployed, this name is the name of your applications package folder (i.e. the django project name).
The name of the environment you are deploying your application into, this is used to determine which configuration should be used. For example production, stage, uat.

These key variables will be used throughout this document.


/opt/webapps/project_name Deploy path
  app Application package deploy path
  current The current package version [1]
  revision/package_name The revision and application package
  bin Binary folder [2]
  include Include folder [2]
  lib Lib folder [2]
  public Public web root for web server
  media Application content or uploaded data [3]
  static Static application content
  var Application variable data [3]
  wsgi.sock WSGI socket
/var/log/webapps/project_name/package_name Project log path [3]
[1]Symlink to the current revision.
[2](1, 2, 3) Virtualenv created folders.
[3](1, 2, 3) Writable by application user.


app Application source root
  package_name Application package [5]
  deployment Deployment settings folder
  settings.*deploy_env*.py Environment configuration [4]
  requirements.txt PIP requirements file
conf Configuration
  init.d Startup scripts for init.d
  nginx Nginx configuration
  nginx.*deploy_env*.conf Environment configuration [4] Project fabric definition file
[4](1, 2) Used to apply specific configuration based on deployment environment.
[5]This structure is based on Django 1.4.

Recent activity

Tim Savage

Tim Savage pushed 7 commits to timsavage/denim

048dee8 - Bumped version number, released to PyPI
f9dfebe - Updated setup file to include correct package data etc
574a07c - Updated supervisor test cases
dfbb89a - Fixed pep8 raised issue with dict as default param
59f96e8 - Added option to django recipe to override symlinking settings (useful if customising the environment via using different settings in supervisor config)
Tim Savage

Commits by Tim Savage were pushed to timsavage/denim

b1b4014 - Added tests for package/debian, updated test._utils to help with result object tests.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.