Ruby on Rails RVM + NGINX + Unicorn + Capistrano

dreamcompute

#1

Ruby on Rails Launch Cheat Sheet
NGINX + Unicorn + Capistrano on Dreamcompute

Make a new Volume from image Ubuntu 14. Launch instance from this volume. Attach ip address.
It’s crucial you start with a new Volume otherwise in your Dreamcompute dashboard you won’t be able to create snapshot. This is going to be useful for setting up staging after we got our rails app serving up a hello world.

[list=1]
[*]Add user deploy with sudo priviledges


sudo adduser deploy # you can also do appname-deploy but i'm forgoing the hyphen and app name prefix
sudo adduser deploy sudo # gives new user sudo priviledges
su deploy

# adduser is a perl script which makes use of useradd on the backend.  It does more then useradd (e.g., adding user to groups, granting sudo)

mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys
chmod 700 ~/.ssh/ && chmod 600 ~/.ssh/authorized_keys

# on your local machine copy the public key
cat ~/.ssh/id_rsa.pub | pbcopy

# use nano or vim on server to paste key
nano ~/.ssh/authorized_keys

# sshd config necessary for the new user to log in
sudo vi /etc/ssh/sshd_config

I allowed both users out of fear of over riding any defaults for dhc-user and preventing us from logging in. No semi-colon or commas needed if you want to brave it you can change the port as well. Details like this will be in version 2 of the guide you can also do deploy@ip-address to be more strict. Add this to your sshd_config

# /etc/ssh/sshd_config

AllowUsers deploy dhc-user

sudo service ssh reload Now get out of your server… logout… and log back in with deploy@ipaddress and you should be able to log in with the new deploy user.

After some research I found this which makes use of a permissions group called www-data

Check that your username is in www-data group and make sure you’re logged in as the new user deploy

cat /etc/group
sudo adduser $USER www-data
sudo chown $USER:www-data -R /var/www
sudo chmod 0755 -R /var/www sudo chmod g+s -R /var/www

as of writing this dhc-user is not included into this group. So it will be left out for now but may be added later.

[*]Install RVM

some code

[*]Step three

more code

[/list]

Stop me now if you don’t want this here. I have to make a cheat sheet today so I’m willing to share it on this message board to help people as well as a blog post to show up on google index for “dreamcompute ruby on rails”. All I ask is if you add this to the companies wiki you put that ladymonkey did it lol.

If any of the dev’s and users that monitor this board are in fact Ruby fans it would be great to have your feedback. I will also be breaking down Capistrano Deployment steps but not in this thread.

Hopes and Dreams

To develop a Capistrano Module to ease deployment steps further. I’m open to feedback and suggestions. Heroku makes it ridiculously easy to launch a Rails website. It would be great to do something for Dreamcompute.

Feedback
Workflow! I’m curious for people whats the most optimal way to setup your web apps? I’m going to try some new things and am completely open to criticism.


#2

I’m definitely not going to stop you! Feel free to continue and we’ll gladly give you credit.

Also, we’re working on an application launcher for DreamCompute that will make it easy to launch instances running specific apps or services. We’ll look into creating one for Rails.


#3

hi ladymonkey, in fact we like Ruby and have been working on documentation to launch instances and deploy applications directly via Ruby Fog.

See the wiki for http://wiki.dreamhost.com/How_to_use_ruby_fog_to_create_delete_instances and http://wiki.dreamhost.com/How_to_deploy_an_application_to_an_instance_with_ruby_fog

We’d love to have your feedback on those tutorials, too.