Skip to content

Django Dokku template based on django-dokku-template, but with extra functionalities.

Notifications You must be signed in to change notification settings

Tirzono/django-dokku-template-plus

Repository files navigation

Django Dokku Template

Template

Using this template to create a new Django app is easy:

django-admin.py startproject --template=https://github.com/Tirzono/django-dokku-template-plus/archive/master.zip -e py,md,example,json,sh,js,yml,ini -n Procfile,Dockerfile {{ project_name }} .

Configuration

Application

To create the app:

sudo dokku apps:create {{ project_name }}

Set your environment on the dokku server:

sudo dokku config:set {{ project_name }} DJANGO_SETTINGS_MODULE={{ project_name }}.settings.production
sudo dokku config:set {{ project_name }} SECRET_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)

Database

Install postgres and create a new database:

sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
sudo dokku postgres:create {{ project_name }}
sudo dokku postgres:link {{ project_name }} {{ project_name }}

RabbitMQ

To create and couple RabbitMQ:

sudo dokku plugin:install https://github.com/dokku/dokku-rabbitmq.git rabbitmq
dokku rabbitmq:create {{ project_name }}
dokku rabbitmq:link {{ project_name }} {{ project_name }}

Letsencrypt

To generate a SSL certificate with Letsencrypt, run:

sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
dokku config:set --no-restart {{ project_name }} DOKKU_LETSENCRYPT_EMAIL=<EMAIL>
dokku letsencrypt {{ project_name }}

Slack

To notify Slack when the deployment succeeds, run:

dokku plugin:install https://github.com/ribot/dokku-slack.git
dokku slack:set {{ project_name }} <URL>

Development

Yarn will be used for frontend packages. To install all packages, run:

yarn

To add a frontend package, run:

yarn add <package_name>

To generate the Javascript and CSS file, run:

gulp

Compile requirements

In order to compile the requirements from requirements.in, run from the root directory:

pip-compile

This will automatically generate requirements.txt and all its dependencies.

Deployment

Deployment can be done with Bitbucket Pipelines. Set the following parameters:

  • DOKKU_USER
  • DOKKU_HOST
  • DOKKU_PRODUCTION_APP

Where DOKKU_PRODUCTION_APP is equal to {{ project_name }}.

A Vagrant box is present to test the dokku deployment. Run:

vagrant up --provider=virtualbox

Next go to dokku.me to finish the installation and start using the Vagrant box.

About

Django Dokku template based on django-dokku-template, but with extra functionalities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published