Skip to main content

Deploy the Django app to Ubuntu server as docker container.

Project description

Dockdj

Production Quality Django Deployments

Dockdj is a command line tool that allows you to deploy any Django app to your own server.

This tool is inspired by Meteor up tool which is used to deploy Meteor.js app.

You can install and use Dockdj on Linux, Mac and Windows. It can deploy to servers running Ubuntu 14 or newer.

Dockdj is powered by Docker, making deployment easy to manage and reducing server specific errors.

Requirement

This tool needs Python > 3.6

Install

Install the dockdj using following command

$ pip install dockdj

Usage

Lets say you have a Django project with following directory structure.

parent
    - hello_world
    |    - hello_world
    |        - wsgi.py

Create a sibling to the django project directory for saving dockdj settings files which will be used to deploy the django app

$ mkdir deploy

parent
    - hello_world
    |    -hello_world
    |        -wsgi.py
    - deploy

$ cd deploy

$ dockdj init

This will create two files dockdj.yaml and settings.py

parent
    - hello_world
    |    -hello_world
    |        -wsgi.py
    - deploy
        - dockdj.yaml
        - settings.py

Modify the dockdj.yaml file to enter server configuration and app details. Initial file looks as follows.

---
servers:
- host: 1.2.3.4
  # must be sudo without password
  username: root
  pem: "~/.ssh/id_rsa"
  # optional
  env:
    PER_SERVER: abc
app:
  # Any name used by script to name docker
  name: abc
  # Django app dir which contains wsgi.py and settings.py
  django_app: 'hello_world'
  requirements_file: 'requirements.txt'
  port: 80
  # Django app dir which contains wsgi.py and settings.py
  path: "/path/to/project"
  docker:
    image: python:3.7
  env:
    FOO: foo
    BAR: bar

settings.py fill contains settings which will be appended to your django app's settings.py file. You can enter production related settings or override development settings here. Initial settings.py file looks like as follows.

DEBUG = False

# Add the your servers host name or ip address
ALLOWED_HOSTS = ['1.2.3.4', 'www.example.com']

After editing these two files appropriately run following command to setup server. This will install docker in Ubuntu servers if not already installed.

$ dockdj setup

To deploy the django app run following.

$ dockdj deploy

This will create docker image of your Django app. Runs the Django app using gunicorn and binds the port to the port specified in dockdj.yaml.

Django manage.py

You can run manage.py script on server using manage sub command as follows.

$ dockdj manage migrate

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dockdj-1.3.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

dockdj-1.3.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file dockdj-1.3.1.tar.gz.

File metadata

  • Download URL: dockdj-1.3.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.1

File hashes

Hashes for dockdj-1.3.1.tar.gz
Algorithm Hash digest
SHA256 f07fdba1b26ae27d27891325d8cca5e364c5c8fa01085974d1d9a0ec871c7935
MD5 c24e256a07a26343d6719b13a8d1d13b
BLAKE2b-256 6eeb6bb5cb40ee4684678fb93be9a98941db04674ccbee7037b6906378e33a24

See more details on using hashes here.

File details

Details for the file dockdj-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: dockdj-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.1

File hashes

Hashes for dockdj-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6624968fdc9e958f9b2d7d62793d40acd9dc311803b43aa348ec63d99189928
MD5 cab16084e42849995a41936368d8ee98
BLAKE2b-256 94979e8a57de7c697d0ba3f95bef80372355a54ac41d0eb35d1ca076728bafe2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page