Packaging rails app - ruby-on-rails

I have a rails application that I'm trying to use on other machines that do not have ruby, rails, or bundler installed. Is there a way I can zip up the rails application, the ruby environment and all its gems / dependencies? I'd like to be able to just send the zipped file to a computer without ruby and be able to run the application without having to install ruby, rails, bundler and all the gems in the rails app.
I've tried traveling-ruby, but it just packages ruby and not rails or bundler.
Edit: For clarification, the app is an internal tool for work. We would rather not deploy the app to a server, but rather just share the whole package with computers that may or may not have the dependencies installed.

You should consider Docker to prepare a "package" of self sufficient environment for your application. This way you will be able to send it to another machine and run without problems. You can use those containers for development purposes only. There is no requirement to deploy them into a server.

Related

What is the best way to package a Ruby on Rails Application?

So I have created a ruby on rails application that functions as a basic calculator. Now I want to package this application up, upload to github, download onto Jenkins, and create a Jenkins job that will run this ruby application.
Normally if this was a Java Application, you would package it as a jar file and then run the jar file. What would I package this Ruby application as?
I thought about packaging this application as a Ruby Gem, but aren't Ruby Gems mainly for when you want to use your ruby app inside of another ruby application? I want to run this app as a stand alone application.
Even if I were to package the Ruby on Rails app as a Ruby Gem, how would I run the gem as a stand alone gem? What would be the command to run it as such from the command line?
Unlike Java applications that have packaging as a first class citizen(be it a jar or a war) this concept isn't baked in most development environments.
That's why there a big push towards docker, it allows you to insulate your app(and gem dependencies) and plug it into the production environment much like dropping a war into a container.
Here's an article about dockerizing a Rails app:
https://semaphoreci.com/community/tutorials/dockerizing-a-ruby-on-rails-application

Ruby on Rails: How to deploy an app on remote linux server

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)

can't get past AWS Elastic Beanstalk "Congratulations" screen when launching Ruby on Rails app

I followed all of the directions and this is the result.
I'm in the process of creating the .rvmrc file at my application root path, as well as the setup_load_paths.rb file in my /config folder as described here. I did all that, and then I realized my computer is using ruby 1.9.3p194. While the EC instances is using 1.9.3p286. So I'm in the process of matching them up and re-creating the .rvmrc file.
While doing that, I noticed that the beanstalk ec2 server doesn't even have rails installed. I should be able to type rails --version I assume and see the version like I can on my computer and with ruby --version on the server. So I'm installing RVM, with and rails (as I've done in the past) on my new beanstalk ec2 server. But in general, it seems this all defeats the purpose. It's supposed to be somewhat automatic. Installing rails definitely doesn't sound right. Was it installed another way on the server?
Any advice on how to get the new beanstalk support for ROR working? What am I doing wrong?
From the error in your passenger exception it looks like Bundler was unable to locate the Ascii85 gem in your remote sources. Your remote source should be listed in your Gemfile at the top line in the form:
source :rubygems
If this is not working, try specifying the source explicitly in the form:
source 'http://rubygems.org'
Note that you should not be doing anything special for RVM/Passenger integration in a deploy. In fact, any extra specialized integration may actually cause problems with Elastic Beanstalk if any platform details change. You should be building your application using standard Rails conventions.
As far as rails -v failing: Rails is brought in via your Gemfile, which relies on bundle install succeeding. Your passenger error shows that Bundler failed to resolve your dependencies against your remote sources, which likely means that Rails was also not installed. In other words, Rails will only be available if the bundle installation succeeds.

Distribute Ruby on Rails app

I'm trying to figure out a way to distribute a Rails application in a fairly standalone way. Think of Sickbeard or CouchPotato, two apps you only need Python to run.
That's basically what I want to achieve, but with Rails instead. There are some failure stories out there and some that are just too complicated, but I'm hoping that there has been some advancements in the field that I just can't find.
Is there a way to distribute a Rails application including any gems it depends on in a way you only require Ruby installed to run it?
I have no intention of trying to obfuscate the source code.
Just use Bundler. Mostly every new Ruby installation have RubyGems and Bundler in standard so the only thing that End-User should do is:
$ bundle install
$ rails s
And will get running app with all dependencies installed.

Correct way to set up Rails environment?

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.

Resources