What is Dokku?
Dokku is an open source platform as a service that runs a single server, similar to Heroku. Click here to visit their website.
Configure your VPS on a Linode server.
Some configurations are required in order to achieve a better performance in Dokku. The configurations are:
- Open your server’s dashboard in the Linode Manager.
Make sure your Linode is using KVM, not Xen, for virtualization.
In the “Rebuild” tab, select “Ubuntu 14.04 LTS”, set a root password, and rebuild.
Once your Linode has been created, click “Boot” and wait for it to complete.
SSH into your server as root and run the following commands:
When prompted, install Grub into the first hard drive.
apt-get update apt-get -qq upgrade apt-get install linux-image-virtual linux-image-extra-virtual
Back in your server’s dashboard, click “Edit” on its Configuration Profile
Change the “Kernel” option to “GRUB 2” and save your changes.
Lastly, reboot the Linode.
This changes are necessary because of Docker has a better performance with AUFS.
To install Dokku, access your Linode using ssh and run the following commands:
wget [https://raw.githubusercontent.com/dokku/dokku/v0.7.2/bootstrap.sh](https://raw.githubusercontent.com/dokku/dokku/v0.7.2/bootstrap.sh) sudo DOKKU_TAG=v0.7.2 bash bootstrap.sh
After installing Dokku, you should configure the ssh access and the virtualhosts in order to respectively deploy and access your app through a browser. Open your browser and enter the IP address of your Linode. There are a few parts that you need to configure here. See the following images.
In your terminal run the following command:
If you want to use a subdomain, check the option 'Use virtualhost naming for apps'.
Create a new dokku application
In order to create a new application in the Dokku, it is necessary to access your server via ssh and run the following command:
dokku apps:create <app-name>
Install Postgres plugin
By default Dokku don’t come with a database. Therefore, we’ll need to install a plugin to work with Postgres or MySQL. Let’s stick with Postgres, run the following command to install the plugin:
sudo dokku plugin:install [https://github.com/dokku/dokku-postgres.git](https://github.com/dokku/dokku-postgres.git)
Run the following command to create a new service. It is necessary fill the service name, but it is not necessary to use the same app name. Create a new services with name, not necessary some name your app. Run the command:
dokku postgres:create <serviceapp-name>
Access your server to link the postgres service to your app. Run the following command:
dokku postgres:link <service-name> <app-name>
List of commands to postgres plugin
postgres:clone <name> <new-name> Create container <new-name> then copy data from <name> into <new-name> postgres:connect <name> Connect via psql to a postgres service postgres:create <name> Create a postgres service with environment variables postgres:destroy <name> Delete the service and stop its container if there are no links left postgres:enter <name> [command] Enter or run a command in a running postgres service container postgres:export <name> > <file> Export a dump of the postgres service database postgres:expose <name> [port] Expose a postgres service on custom port if provided (random port otherwise) postgres:import <name> < <file> Import a dump into the postgres service database postgres:info <name> Print the connection information postgres:link <name> <app> Link the postgres service to the app postgres:list List all postgres services postgres:logs <name> [-t] Print the most recent log(s) for this service postgres:promote <name> <app> Promote service <name> as DATABASE_URL in <app> postgres:restart <name> Graceful shutdown and restart of the postgres service container postgres:start <name> Start a previously stopped postgres service postgres:stop <name> Stop a running postgres service postgres:unexpose <name> Unexpose a previously exposed postgres service postgres:unlink <name> <app> Unlink the postgres service from the app
Deploying your app
In order to deploy your app you will need to add a remote link.
git remote add dokku dokku@ip-or-domain:<app-name>
After that you can deploy your app with git push, for example:
git push dokku master
To run any rake, it is necessary that you access your server via ssh and run the following commands:
dokku run <app-name> rake <rake-task>
That’s all folks! Your application is up and running on a Linode Server.
Thanks to Dmitry Rocha, Marcle Rodrigues, and Will Soares.
We want to work with you! Check out our "What We Do" page.