Setting up a Docker-Compose that will set up a Rails dev enviroment for local development - ruby-on-rails

I’m new to Docker, I think I’m getting it down for server setup using docker, however I want to use Docker so non-engineer staff in my company can more easily setup a Rails dev enviroment, database, installing libraries on the ruby and javascript end, that kind of thing.
I can do it using Docker, however it requires getting into the docker engine and tweaking databases and what not which I feel is asking a lot for a non-engineer persons and doesn’t lessen there burden as just setting them up natively.
I’ve looked around on guides to setup Rails environments but they all tend to have a lot of work required to get everything up and running, I wish to have a more easier way of just fire up terminal and go to the project folder, smack 1 or 2 commands in and have it all done, is there any guide or example setup to do something like this?

Related

deploying a rails project to a remote server

is it possible to deploy a rails project to a remote server using FileZilla ? the server is running nginx/1.4.6 (ubuntu)
if no what is the best way to deploy the project if there is already a running version !
To answer your question yes, the code needs to be up, so FTP should do the trick. You might need to restart nginx to pick up the changes, usually touching a restart.txt is enough, but that's particular to your setup.
Is this the best way? Possibly not!
Others suggested capistrano and that would be a good fit for a server you maintain, or go Heroku (or similar) service for a simpler setup.
Deploying a Rails app is a tough job. There is always the easy way (heroku) however shared servers don't deal well with rails. Theoretically you can but usually this shared servers have really outdated ruby and rails versions and are absolutely useless. And you can try to connect via ssh and try to update it but i doubt you will be able to do that. So... If you are a rails developer i can suggest.
1- For small apps run Heroku (easy and free) however cost grows like hell with the app's growth
2- If you're thinking about developing big apps get a dedicated server (you can get cheap ones for 5€/month) and configure it as u would for your computer except when you run rails you run it in production.
3- Trust me... i fought enough Rails and shared servers and i quit... I just gave up

How to create a VM that mirrors the RoR production version

I am working on an open source project and there is an issue where an upload error only seems to occur on the production side that is running apache and unicorn.
Due to privacy issues and risks, I am unable to mess around in the actual production side (such as creating a temp id for myself with various privileges.
Is there anyway that I can quickly create a VM with such setup in my own computer that would mirror the live site?
The site is running in RoR 4, latest unicorn, and latest stable version of apache.
There are a couple of ways you can be able to accomplish this. You can use vagrant and also with the rising popularity of Docker containers, you can easily model production environment on your computer. Since you indicated a faster way to get the VM up and running, I would recommend using railsbox.io. Its amazing and it saves you a lot of time. According to their webiste -
Fast and easy Ruby on Rails virtual machines. Streamline your
development workflow in no time by creating production-like virtual
machine with your development environment. Try this extremely simple
to use VM configuration tool to create new Ruby on Rails server using
vagrant and ansible.
The app helps you setup a VM with ease.

Deploying Ruby on Rails Apps with Mongoid (MongoDB), Redis, Resque, Capistrano, etc

I am creating a Ruby on Rails website deployed on AWS. I am running into configuration issues and I can't seem to find docs/tutorials that cover configuration of the various tools mentioned and how to set them up BOTH for ease of use in development (on localhost) and while deploying.
Right now I have a Rails app set up and I am using Bundler for all my Ruby gems.
I have two major goals.
Ease of development - Ideally somebody should just have to clone the repo and run 'rails server' and should be good to go. All other stuff like Redis servers, Resque workers, Mongo DB databases, should automatically be started/created.
Ease of deployment - Given some configuration file (like YAML files), I should be easily able to deploy to various stages by simply running 'cap production deploy' or something similar. It should automatically run all the rspec tests, and prevent deploying if something goes wrong. Once deployed it should also handle all other aspects like restarting Apache/Nginx, handling DB migrations, restarting Resque workers, etc. I know how to do this all manually, but again I am looking for a solution that will let a novice (i.e. unexperienced with my app's deployment process, not novice in general) easily be able to deploy.
I have looked at various tools/gems like Foreman, God, etc. but I am not clear on how to use them correctly and how they work in different environments like development and production.
I am looking for either docs/tutorials on how to do this or even Github repo's of Rails app that have solved these problems (preferably smaller repo's so that I don't have to wade through application specific stuff to get the information I looking for).
I am also looking for a way to monitor my Rails app. As what kind of errors are happening? how frequently are they happening? Is Splunk a good tool to do so?
Note : I am not tied down to use any of the tools mentioned above, since I am only starting to develop my website.
This is pretty comprehensive if you want to deploy to a small EC2 instance using Capistrano and Apache.
For monitoring I'd suggest New Relic or just checking your logfiles.
However, you're going to have to be more specific about your technology questions. You're covering a lot of breadth here and going deeper into answering this would require a lengthy essay and possibly a consulting fee.

How to install Ruby script on server?

I apologize in advance for the fairly simple question.
I am familiar with PHP, but am trying to install this Ruby script on my server for the first time. It's an open source script that I've forked from github, but unfortunately does not have any instructions. I have Ruby on Rails, and MongoDB installed already.
Does anyone know what the beginner steps are to get started? Should I upload everything via FTP to the public directory, or is there something else to this?
Most Rails projects are much better served by having a proper deployment strategy. Typically this involves making your own repository, easily done by forking that existing application, and cloning that on to your server using git. To make changes in the future, do your work on a development copy, push that into the repository, and pull down the changes on the server.
Unlike PHP where many parts of the application can function independently, Rails applications tend to be far more integrated and uploading it piece by piece is not going to work in the long run.
Rails applications can run stand-alone using the provided rails server tool but this is really only intended for light-duty testing or development work. A more permanent solution is to use something like Passenger to do the hosting for you.
Passenger will take care of launching your application when calls are made to the site you've configured in Apache or nginx, depending on which you end up using. Passenger is popular because it's quite easy to get running.
There are other approaches like unicorn if you're feeling more adventurous.
When you make changes to your Rails application in production mode you will have to create a tmp/restart.txt file in the main application directory to tell your web server to restart the process. This is not a requirement in development mode.
Due to the relative complexity of this process once you include all the various steps, you will probably want to use a deployment automation tool like capistrano.

Why is it supposedly "hard" to deploy Ruby on Rails to production?

I admit that I don't follow much of anything "right" on deploying test versus production code. I have been using ASP.NET, and I typically run it locally in Visual Studio, it works, I upload it, I test it again on the production server.
I have read several people say that deploying Rails apps is harder and there are special programs/ways on the ruby site about deploying RoR. I've only toyed with RoR. What is special about deployment? You don't just copy and paste the code and run it (from development machine to the production)? Is it because one is in Apache and the other running on the built in server?
This will be on a Mac Server if it matters.
Deploying RoR is not difficult anymore, especially with Phusion Passenger.
What is somewhat difficult, is getting a automated production environment setup with capistrano, vlad, etc. If you don't mind simply copying your code to the server, you can do that just fine. Most people choose not to do it that way because you lose out on a lot of the benefits that the automated deployment tools give you.
I guess people consider a Rails app harder to deploy than say some PHP apps or such where you just plop the code somewhere and point Apache or whatever at it. But, as mentioned above, you could do that now with Phusion Passenger.
We use Nginx+Passenger, but not for simplicity of deployment. Capistrano is our deploy tool of choice, and really, unless you have a very simple app, you're going to want something like Capistrano anyway. For example, with our deploy, we do a slew of things:
run any database migrations
generate release notes automatically, based on all the commits to Git between the last deploy and this one
notify various people via email (with differing lists depending on whether the deploy is to our staging environment or production) - we do this via cap_gun which integrates with Capistrano.
Notify New Relic RPM of the deploy so it can mark it in our RPM analysis
Notify Hoptoad of the deploy, so it too can have that data when reporting any exceptions
produce our sitemap.xml file, and ping Google to tell them there's a new one
update crontab files (I store our crontab files for each server in our git repo, and then on deploy it sees if there is a new version and updates accordingly, etc.).
flush/restart memcached
There are other ways aside from Capistrano, but it's a proven tool, with a lot of flexibility, yet pretty simple to setup a vanilla configuration.
So, my take is that once you get into any app that is beyond just the very simplest of apps, you're going to need/want to be doing things other than just simply updating the code. In the beginning though, if you just need the code updates, and maybe Rails migrations, then you can do simpler things like Passenger and code sync, or look at tools like Heroku or Engine Yard's stuff where they do a deploy by doing a Git clone (and then offer some additional abilities).
Another super easy way to deploy is with http://heroku.com/
Some of the issues you face with deploying rails to production:
Database connection.
You need to be sure that the database connector is set up for the production environment.
Database migrations.
You have to run database migrations against the production database even though you may have already run them in production/testing/staging
Ruby version. The version or sub-version or Ruby can trip you up, e.g. An error occurred while installing debugger-linecache (1.1.1), and Bundler cannot continue
Gem dependency.
Your production environment may have different packages and gems from development. Bundler will figure this out for the most part and install the dependencies but occasionally there are still issues that you have to resolve manually.
Dependencies.
Some gems on some machine have particular dependencies. I have seen frequent problems with using gems on my unix box that work on OSX and vice-versa.
Note the last 3 shouldn't affect you if on the same machine but I included them based on the title and to be comprehensive.
It's not especially hard. If you stick to conventions then with a little bit of configuration it boils down to this:
cap deploy
...however there is sometimes a bit of effort needed up front to get the workflow in place.
The good news is that lots of people have packaged up solutions and stacks for RoR that you can just plug and play. For example, google ec2onrails - this is a packaged Ubuntu image and set of capistrano tasks for running rails apps in Amazon's EC2 cloud, with lots of common stuff set up already out of the box.
Choose a good hosting provider and you should be able to find something similar for that also.
An easy way to deploy Rails apps is to use Phusion Passenger. Deployment doesn't get much easier than that for any programming language or framework. You can do that on a Mac server.
Another really easy way to deploy rails is with jruby and the glassfish gem.

Resources