Dokku is a Platform-as-a-Service (PaaS) engine which allows for simple git push
deployments.
It builds on herokuish
and is highly customizable via plugins.
To deploy a Frab application with dokku
, please proceed as follows from within your local source repository.
Given you have access to your Dokku service via a simple shell alias (alias dokku='ssh -t dokku@<DOKKU_HOST>'
) and dokku version
works, you will also need to install the PostgreSQL and Let's Encrypt plugins.
You can then proceed setting up your application.
dokku create <APP_NAME>
Set up your Ruby version:
dokku config:set CUSTOM_RUBY_VERSION 2.3
For your application you need
- an environmental configuration,
- an attached database and
- a valid TLS setup due to Rails' CSRF protection.
Your local .env
environment file could then look similarly to
SECRET_KEY_BASE=<should_be_longer_than_32_chars, 'pwgen 32' suffices>
FRAB_HOST=<APP_FQDN=APP_NAME.DOKKU_HOST>
FRAB_PROTOCOL=<http|https>
FROM_EMAIL=<[email protected]>
SMTP_ADDRESS=<SMTP MX>
SMTP_PORT=25
SMTP_NOTLS=<true|false>
SMTP_USER_NAME=
SMTP_PASSWORD=
BUNDLE_WITHOUT=development:test:mysql:sqlite3
RAILS_SERVE_STATIC_FILES=true
Pipe this configuration to Dokku with
dokku config:set <APP_NAME> `paste -d " " -s .env`
The associated database service is created and linked with
dokku postgresql:create <DB_NAME>
dokku postgresql:link <APP_NAME> <DB_NAME>
dokku config <APP_NAME>
should now report your whole configuration.
This will only work after your application is (already partly) running, due to the way the Let's Encrypt plugin works, so let's
Add the desired APP_FQDN
domain to the application and remove the standard Dokku subdomain APP_NAME.DOKKU_HOST
for later generation of a valid TLS certificate.
dokku domains:add <APP_NAME> <APP_FQDN>
dokku domains:remove <APP_NAME> <APP_NAME.DOKKU_HOST>
Only then issue
git remote add dokku dokku@<DOKKU_HOST>:<APP_NAME>
git push dokku master
To omit an appearing 502 Bad Gateway error, we finish the TLS setup with
dokku letsencrypt <APP_NAME>
After this has completed successfully, manually load the database schema
dokku run <APP_NAME> bundle exec rake db:setup
That's it. Your application should be running at <PROTO>://<APP_NAME>.<DOKKU_HOST>
.