Dokku version: v0.7.2
There are a lot of articles on how to deploy Rails with Dokku on DigitalOcean, but not so many about Linode. So the following article is another article on how to deploy Rails with Dokku to Linode server, based on docs, and own experience.
In case you want to connect domain to your application and you want to avoid possible problems in the future, it is better to change domain NS servers before deploying.
Linode NS servers:
Then you should add your billing information. And probably Linode will ask you what amount of money you want to transfer to your account, 5$ is a minimum. Also, you could search in google promocodes. I found a promocode for 20$ here: retailmenot.
Go to Linodes, and choose a plan and location
According to the tutorial, take the following steps:
In the "Rebuild" tab, select "Ubuntu 16.04 LTS", set a root password, choose SWAP size(I chose 256MB), setup Deployment Disk Size(I choose all available space) and press Rebuild.
Once your Linode has been created, click "Boot" and wait for it to complete. SSH into your Linode as a root and run the following commands:
apt-get -qq upgrade
apt-get install linux-image-virtual linux-image-extra-virtual
When prompted, install Grub onto the first hard drive. Back in your server's dashboard, click "Edit" on its Configuration Profile, change the "Kernel" option to "GRUB 2" and save your changes and reboot the Linode.
Connecting Domain to Linode
Go to DNS manager zone, fill in the fields and save. In the section “Insert Default Records” choose the first option and select linode where you will deploy the application.
Go to Remote Process, click “Reverse DNS”.
And look up your domain.
ssh root@ip_address #ssh to server
DOKKU_TAG=v0.7.2 bash bootstrap.sh
After the installation go to the browser http://<your_server_ip>
Enter your ssh key. In case before the installation you copied ssh key to the server, this field will be prefilled with it.
Type hostname(your domain). In case you don’t have a domain, you could enter your server ip address.
First of all you need to create a dokku application. SSH to your server and make:
dokku apps:create app_name
Then we should create a database. Dokku has a lot of plugins. In our case we will use Postgres.
Install plugins, create a database service, link the database with your application.
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres
dokku postgres:create db_name
dokku postgres:link db_name app_name
It is possible that you need to set “config vars”. In case you have in gitignore the configs that you don’t share in your repository, set config vars, it is easy.
dokku config:set app_name PASSWORD='password'
I also recommend you to change timeout configs. At least I had a problem with it during deployment.
dokku config:set --global CURL_TIMEOUT=600
dokku config:set --global CURL_CONNECT_TIMEOUT=30
Deploying to dokku is pretty similar to heroku. You could check the instruction Getting Started with Rails 4.x on Heroku.
git remote add dokku dokku@ip_addres:app_name
git push dokku master
In case of any troubles, please look at the special page on dokku site troubleshooting.
I had one problem related to permissions while connecting database with app.
chown dokku: DOCKER_OPTIONS_DEPLOY
Thank you for attention!