Skip to content

Instantly share code, notes, and snippets.

@gorborukov
Last active April 30, 2016 21:52
Show Gist options
  • Save gorborukov/ce66c921d063bdfd3011 to your computer and use it in GitHub Desktop.
Save gorborukov/ce66c921d063bdfd3011 to your computer and use it in GitHub Desktop.
Easiest way to deploy Rails 4 app to DigitalOcean with Dokku
  1. Create one-click install Dokku droplet don't associate any ssh keys on this step

  2. Enter ssh-keygen -t rsa on your local machine and follow instructions

  3. Enable ssh access to remote server without password from your machine: cat ~/.ssh/id_rsa.pub | ssh [email protected] "sudo sshcommand acl-add dokku dokku"

  4. Login to remote server ssh root@YOUR_SERVER_IP

  5. Create new Dokku app: dokku apps:create myapp

  6. Install psql Dokku plugin: before install set postgres version to 9.4: dokku config:set --global PSQL_SC_IMAGE=postgres:9.4 dokku plugin:install https://github.com/Flink/dokku-psql-single-container

  7. Create postgres database: dokku psql:create myapp

  8. Display database connection info 'dokku config myapp'(keep this window opened or copy info to clipboard), setup existing ssh key for Dokku: cat /root/.ssh/authorized_keys | sshcommand acl-add dokku dokku

  9. On local machine create new Rails app: rails new myapp --database=postgresql && cd myapp

  10. Init new git repository in app directory and add remote: git init && git remote add dokku [email protected]:myapp

  11. Open gemfile and add: gem 'rails_12factor', group: :production

  12. Run 'bundle install' in your rails app directory

  13. Open config/database.yml and setup database connection for production (You can find necessary information in step 8). For example: production: <<: *default url: <%= ENV['YOUR_URL_HERE'] %> database: db_myapp username: db_myapp password: YOUR_PASSWORD_HERE host: postgres

  14. Save all edited files

  15. Commit changes: git add . && git commit -m 'your commit information'

  16. Deploy your app: git push dokku master

PROFIT!11

And some usage tips:

  1. Use 'ssh dokku@YOUR_SERVER_IP run myapp rake db:migrate' for database migrations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment