#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
orNew Relic
(not in this guide)
##step 1
at digitalocean.com
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
- add postgres with following this guide:
https://github.com/Kloadut/dokku-pg-plugin
- run
dokku plugins-install
if you haven't already
*if there're issues while trying to install plugins because of some nginx errors, uninstall nginxapt-get remove nginx
and reinstallapt-get install nginx
(or any other package for that matter)
##step 4 tunneled into server except # 2 done locally in your application codebase
- create database
dokku postgresql:create <app_name>
- change
database.yml
to use url environment variableurl: <%= ENV['DATABASE_URL'] %>
- 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
- go to server IP address in browser and set SSH key and app naming url
##step 6 done in your local console
- 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 instructions if having trouble:https://github.com/progrium/dokku
cat ~/.ssh/id_rsa.pub | ssh root@<your_ip_address> "sudo sshcommand acl-add dokku dokku"
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
https://github.com/progrium/dokku#environment-variable-management
##step 8 in browser
- 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)
- test in browser!
<app_name>.rootdomain.com
##Reference
- https://github.com/progrium/dokku
- https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-dokku-application
##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!
This has been very helpful for me when learning more about Docker http://www.youtube.com/watch?v=mVN7aTqr550