Skip to content

Instantly share code, notes, and snippets.

@suhaibshahid007
Created February 17, 2023 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suhaibshahid007/4558877bb01332bfbf9b9c4ffa2fcd49 to your computer and use it in GitHub Desktop.
Save suhaibshahid007/4558877bb01332bfbf9b9c4ffa2fcd49 to your computer and use it in GitHub Desktop.
Deploy Rails App to Digital Ocean server using dokku
Create a project on Digital Ocean.
Create a new droplet using ubuntu(20.04 LTS), select server regiond, other specs, add your public SSH key and take the IP address.
Then ssh into VPS using command - ssh root@<ip-address>
Then install dokku there by using the command - wget https://raw.githubusercontent.com/dokku/dokku/v0.28.4/bootstrap.sh;
sudo DOKKU_TAG=v0.28.4 bash bootstrap.sh . For more Info can follow this link (https://pawelurbanek.com/rails-heroku-dokku-migration)
Then Specify your app name using command - dokku apps:create my-rails-app
Add dokku plugins for rails app to install postgresql/redis (sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git sudo dokku plugin:install https://github.com/dokku/dokku-redis.git redis)
Need to configure public SSH keys to accept by dokku remote. (echo 'YOUR_PUB_KEY' | dokku ssh-keys:add admin)
After that, need to add dokku remote just like we usually do for heroku by using this command - git remote add dokku dokku<ip-address>:<app-name>
Then verify remote by using command - (git remote -v) and then push git push dokku staging
While deploying repo, may get some issues related to bundler/assets precompile. Fix all them and then push agin to dokku.
After that the deployment will complete, but still we need to add the domain in dokku. For new apps in most of cases, we will have ip address that will be add by using the command - (dokku domains:add claims-validation-api <ip-address>, dokku domains:set claims-validation-api <ip-address>). It will automatically reload Nginx.
Can check the apps on dokku by using the command - dokku apps:list
Add done - You can access your app now at ip-address like in my case http://167.71.142.58.
--------------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment