How to deploy your rails app to dokku
Get a VPS with Debian or Ubuntu pre-installed. I prefer Hetzner for price performance ratio, vpsbenchmarks has a great overview of the market. At these prices in my opinion it’s worth having two so you can sync a full backup to another location 🙌.
Install Dokku
wget https://raw.githubusercontent.com/dokku/dokku/v0.26.8/bootstrap.sh; sudo DOKKU_TAG=v0.26.8 bash bootstrap.sh
Setup SSH key
cat ~/.ssh/authorized_keys | dokku ssh-keys:add admin
Set a virtual domain
You can use any domain you already have access to, this domain should have an A record or CNAME pointing at your server’s IP, from step 1. This will give you subdomain support for each app you deploy. e.g. myapp.mydomain.com
dokku domains:set-global mydomain.com
Create your app on dokku and link with a database
# remote machine dokku apps:create app-name # install postgres plugin sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres dokku postgres:create app-name-db dokku postgres:link app-name-db app-name
Deploy! 🤞
# local machine # the remote username *must* be dokku or pushes will fail git remote add dokku dokku@mydomain.com:app-name git push dokku main:master
Feb 2, 2023