Skip to content

Instantly share code, notes, and snippets.

@lopezjurip
Last active June 9, 2020 22:26
Show Gist options
  • Save lopezjurip/a817e96ec833e7667274 to your computer and use it in GitHub Desktop.
Save lopezjurip/a817e96ec833e7667274 to your computer and use it in GitHub Desktop.
DigitalOcean+Rails+Puma+Dokku+Postgress
# Based on: http://donpottinger.net/blog/2014/11/17/bye-bye-heroku-hello-dokku.html
# Add to gemfile:
ruby '2.1.2'
gem 'pg'
gem 'puma'
gem 'rails_12factor'
gem 'searchkick'
gem 'typhoeus'
# Create an initializer at 'config/initializers/typhoeus.rb':
require "typhoeus/adapters/faraday"
Ethon.logger = Logger.new("/dev/null")
# Install it
bundle install
# On config/database.yml set:
production:
url: <%= ENV['DATABASE_URL'] %>
# On your app root folder create a file named 'Podfile' and write:
web: bundle exec rails s Puma -p 5000
# Push to your git at master branch
# Create droplet with Docker, do NOT check IPv6.
# Start with ssh key.
# Go to your DNS provider and setup it with your ip, be sure to set a CNAME with your default domaind and a subdomian wildcard.
# Go to youdomain.com
# Set your hostname and check "User virtualhost nameming for apps".
------------------------------
# if something goes wrong, you can delete that droplet and create a new one. If you have problems with:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
# You can use:
ssh-keygen -R <server ip address or yourdomain.com>
------------------------------
# Login to server
ssh root@<ip address>
# Update Dokku
cd ~/dokku
git pull origin master
make install
# On your client computer at your app root folder:
git remote add dokku dokku@<server ip or youdomain.com>:<app_name>
# Example: git remote add dokku [email protected]:myapp
# Lets push to our server
git push dokku master
# If something goes wrong, you can rollback with:
git remote rm dokku
# Lets install some plugins
cd /var/lib/dokku/plugins
git clone https://github.com/Kloadut/dokku-pg-plugin postgresql
git clone https://github.com/luxifer/dokku-redis-plugin redis
git clone https://github.com/bigboxsoftware/dokku-sidekiq sidekiq
git clone https://github.com/rlaneve/dokku-link.git link
git clone https://github.com/jlachowski/dokku-memcached-plugin memcached
git clone https://github.com/jezdez/dokku-elasticsearch-plugin elasticsearch
dokku plugins-install #this one takes some time to complete
## Setup postgres
# Create database, save Url for later use, let's call it <saved_url>
dokku postgresql:create <database>
# Link
dokku postgresql:link <app_name> <database>
# Check db url
dokku config <app_name> | grep DATABASE_URL
# if saved url is not equals to the last displayed, then:
dokku config:set <app_name> DATABASE_URL=<saved_url>
# Migrate
dokku run <app_name> bundle exec rake db:migrate
## Setup elasticsearch
dokku elasticsearch:create <container name, can be you app name too>
dokku elasticsearch:link <same as adove> <app_name>
## Sidekiq
dokku sidekiq:activate <app_name>
# Reindex:
dokku run <app_name> bundle exec rake searchkick:reindex:all
@ismarsantos
Copy link

'Podfile' or Procfile? thanks for share!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment