Using Dokku to deploy a Rails Application

Using Dokku to deploy a Rails Application:
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
#Goal Deploy your Rails App super easily with Dokku on Digital Ocean cheap cheap! ##Notes - Follow 12 factor design (include the rails_12factor gem) - Don't forget your `Procfile` with the command to start up your application server - I prefer using external hosted logging services like `Logentries` (not in this guide) - Set up performance monitoring `AppSignal` or `New Relic` (not in this guide) ##step 1 **at** Spin up a new VPS with Dokku (from experience, I suggest using at least 1GB if you are running both your database and application servers in one Droplet or you run out of memory pretty soon!) ##step 2 **tunneled into server** SSH into your server and run `apt-get update` ##step 3 **tunneled into server** 1. add postgres with following this guide: `` 2. run `dokku plugins-install` if you haven't already *if there're issues while trying to install plugins because of some nginx errors, uninstall nginx `apt-get remove nginx` and reinstall `apt-get install nginx` (or any other package for that matter) ##step 4 **tunneled into server except # 2 done locally in your application codebase** 1. create database `dokku postgresql:create <app_name>` 2. change `database.yml` to use url environment variable `url: <%= ENV['DATABASE_URL'] %>` 3. run `dokku postgresql:link <app_name> <database_name>` (this will link the postgres running on one docker container with my rails app in another docker container by simply configuring the env variable). ##step 5 **in browser** 1. go to server IP address in browser and set SSH key and app naming url ##step 6 **done in your local console** 1. add dokku as git remote (use ip address if don't want to set root domain as A record) `git remote add dokku dokku@<your_ip_address_or_root_domain>:<app_name>` see instruction `` 2. `git push dokku master` ##step 7 **tunneled into server** On the server, run: ``` dokku run <app_name> rake db:migrate dokku run <app_name> rake db:seed dokku config:set <app_name> SOME_VARIABLE=SOMEVALUE ANOTHER_VARIABLE=ANOTHER_VALUE ``` ** ##step 8 **in browser** 1. point your subdomain to your Droplet (VPS)'s IP address (DNS A Record)! (you can choose to point your root domain to your server as well. I don't do this because I usually run my applications on a subdomain and a regular HTML info site on the root domain) 2. test in browser! `<app_name>` ###Reference - - ###Questions I have I'm pretty new to DevOps and stuff (thanks to Heroku). I've deployed Wordpress apps in the past and used Monit to monitor my daemon processes such as MySQL and Apache How would you do it with Docker? If you know something this please leave a comment below!
If you want to be updated about similar snippets, Sign in and follow our Channels