How to install/update rvm on a remote EC2 machine, since we would like to deploy our rails app and its dependencies on new EC2 instances.
use rvm-capistrano => https://github.com/wayneeseguin/rvm-capistrano#readme it has quite good description how to setup everything, I maintain example project to make sure it all works as expected: https://github.com/mpapis/ad - you can check it's capistrano config for details
Related
I have a working ruby on rails app in my local machine running on localhost(REST APi's). I want to deploy it on remote linux server.
I searched it over google, All I got was installing ruby, rails, nginux and others. It's really confusing. To make my app to work in rails environment in linux, is it really necessary to install the entire ruby and rails. Or, is there any binary executable available where we can use it without installing.
What is minimum required software to install or configuration needed to be set to make my app work in production environment?
(For Example, when I deploy nodejs app, All I need is to put the linux nodejs binaries in server without the need for installing the entire nodejs software)
Any help is appreciated!
The process of setting up your production server will be pretty much the same as with setting up your development machine in terms of installing Ruby and its dependencies. There are no binaries that you can just copy over. In addition to that you'll have to install and set up a web server like Apache or nginx.
I recommend this guide by Digital Ocean. It goes through everything from installing ruby, to setting up the database, to configuring the web server.
They have a couple more (here and here), which seem to be very similar, using different application and web servers, but I haven't read them.
You need to do the following:
1) Ensure that you have an installation of the Ruby language, either via your Linux package manager or with rvm or the like. I recommend it be a recent version (2.2+).
2) Copy over your Rails source tree.
3) gem install bundle
4) bundle install (in the project root directory)
I have successfully deployed my ruby on rails application to an ubuntu 14.04 virtual machine in Digital Ocean. I used Apache2 and passenger for the same.
Now I want to deploy it to the same using Capistrano. I am using a mac machine in the developer environment. I have installed Capistrano 3.4. ssh connection has been set up with my local machine and server as well as with my server and my mercurial version control system in bitbucket.
How can I deploy it via capistrano. I tried many tutorials. Many are outdated and I am not even close. I have deployed it in the server in uat environment and the source code is checked out and is kept in the desktop of server. I have also set up a user with sudo privileges.MySQl2 database is also in the same server.Please help me out .
You can see the gist here, there are 4 files
deploy.rb
production.rb
capfile
Gemfile // only the capistrano required gem snippet
But I've configured using nginx and passenger.
I'm working against a variety of constraints that are troubling an EC2 Rails deployment. I'm not allowed to use Capistrano because I cannot save this application to any public git repository (like GitHub) and I also need to retain complete control over which instance on EC2 the Rails application is installed to and be able to modify this easily (adding load balancers, auto-scalers, etc.) on the fly from the AWS Console, so I also cannot use Rubber.
I finally resorted to simply ssh'ing my Rails application directory over to the EC2 instance, but am running into a 'no such file to load' error when running bundle install, specifically the Time gem. Because this is an 'integrated' gem, I think I might just be overlooking something simple. Here are the things that I've tried:
I've used RVM to manage my versions of ruby, rails, rubygems, etc.
Deleting my Gemfile.lock file and re-running bundle-install
Including 'Time' in my GemFile and re-running bundle-install
This application runs without issue on my local development environment, so what am I overlooking?
Note: I am REQUIRED to host on a single EC2 instance. Otherwise, I'd simply deploy to EBS, Heroku, etc.
This was a stupid mistake, also detailed in this question: heroku - cant run rake db:migrate - no such file --Time
I incorrectly had a require statement in a controller for 'Time', instead of 'time'. This was allowed locally, but my ubuntu server ruby environment was not as forgiving. Changing the 'T' to a 't' in my controller and running 'bundle install' resolved this issue completely.
On my system (OS X), I have an application running on Rails 3.1.0, ruby 1.8.7.
I installed Vagrant and set it up with Ubuntu virtual. I created a new project ABC from within the virtual machine and installed ruby 1.9.3 and Rails 3.2.6, on the virtual machine.
Now, when I exit Vagrant virtual machine and want to ssh into it again, from the ABC project directory, it struggles with a conflict in the ABC project's Gemfile:
~/.rvm/gems/ruby-1.8.7-p358#global/gems/bundler-1.1.4/lib/bundler/spec_set.rb:90:in 'materialize': Could not find actionmailer-3.2.6 in any of the sources (Bundler::GemNotFound)
When I remove the Gemfile from ABC project's directory, I can use Vagrant without any issue.
Why is Vagrant checking out project's Gemfile, instead of just running the virtual machine?
Anyone experienced something like this before?
Vagrant uses Gemfile for plugins.
See the documentation for plugins https://docs.vagrantup.com/v2/plugins/packaging.html.
So vagrant thinks that your rails gems are plugins for vagrant and fails.
My current setup uses Vagrantfile detached from rails directory.
I ended up with this settings after I started using Puppet provision scripts, various bash scripts, project documentation folder outside of rails etc.
It makes more sense to keep rails app as clean as possible and not poisoning it with local development tools files (Vagrantfile).
The question is still valid though. I'm not sure whether this qualifies for an Issue report on github...
Thanks Tilo for your response. I will try to ask a better question.
I need to set up a Ruby on Rails Production environment that will only be used to host RoR applications and will be used as a Git server too. There will be no development done to these applications on the Production server. Right now, I forsee the production server hosting a maximum of 5 to 6 applications only. A couple will be company internal only and the rest of the apps will be viewable to the public. The traffic that they will receive is about 12 to 20 hits per week.
I have been given access to a Virtual Machine that will be the Production server and is currently running Ubuntu 10.04 LTS, Apache2, MySQL, and Passenger. There will be two RoR developers using the Production server to host their applications.
My Development Environment of which I am running Ubuntu 10.04 LTS, Apache2, and MySQL on my own laptop looks like this for each project/application:
RVM installed per application, Git,
Ruby 1.9.2 installed thru rvm, Rails
3.0.3, and I have yet to install the Capistrano gem.
My question is I don't understand how to host a RoR application on our production server.
As an example of what might be done to host a RoR application: I am surmising that I will create a user called app1 under the home directory. Next, should I install Ruby system wide or should I install rvm for app1 and then Ruby for app1? What are the steps involved on how to set-up the environment to run an application on a production server?
Can you give me a few setup scenarios, please?
Thanks in advance.
You didn't tell us what you want to use this web-site for... is it company internal only?
just a few users? or is it externally facing the internet? Just one server running everything?
If it's facing the internet, I would certainly stay away from Ubuntu... look at CentOS/RedHat or FreeBSD to install on a production server.
I'd definitely use Capistrano for deployment. Definitely Git.
I would definitely not install RVM system-wide - IMHO it is not robust enough.
I emailed with Wayne Seguin (maker of RVM) and he also uses the method I've outlined in the post below,
using one dedicated deploy user:
For how to deploy ruby-versions and gems with RVM, look at this post:
Installing Ruby offline using rvm
If you really need two versions of Ruby for two different apps, then use two deploy-users!
Each of them has their own default-ruby-version(!) that's why you really need two users :)
and you can install / manage the gems for each project separately under each of the deploy accounts.
You should also put the git repository in each of the accounts, so you can test.