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 }} .
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)
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 }}
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 }}
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 }}
To notify Slack when the deployment succeeds, run:
dokku plugin:install https://github.com/ribot/dokku-slack.git
dokku slack:set {{ project_name }} <URL>
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
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 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.