Emulating Heroku on local computer - ruby-on-rails

I'm new to Heroku and Ruby on Rails and this may seem trivial. But I could not find the answer.
The Google App Engine has a web server application that emulates all of the App Engine services on local computer. Does Heroku have something similar?
Basically I want to run/debug RoR app on local machine before pushing it to Heroku.

If you are on the Cedar stack, there is a local utility called foreman that can read your procfile to simulate how it will run on Heroku. More info about it is on Dev Center here:
https://devcenter.heroku.com/articles/procfile#developing-locally-with-foreman

Heroku CLI has the local command to run your app locally. Without options, it will run the processes defined in the Procfile in the app root, using any environment variables defined in .env:
heroku local
For configuration options such as using different paths for .env and Procfile and local subcommands see: https://devcenter.heroku.com/articles/heroku-local

I use http://pow.cx/ and https://github.com/Rodreegez/powder for that. Is not emulating Heroku, but it allows you to set up a 'production' environment quickly.
Also, check http://devcenter.heroku.com/articles/multiple-environments and consider if you need a staging deploy.

Nothing like that exists for Heroku but to be honest you don't really need it. Develop locally, use Ruby 1.9.2 as that's the heroku default these days - keep in mind the constraints of Heroku http://devcenter.heroku.com/categories/platform-constraints. Use Postgres locally since that is what heroku shared DB is and you'll be off to a good start.

Related

Dokku error /var/lib/dokku/plugins/available/pg-plugin/plugin.toml: no such file or directory

So here what I did and the following output:
root#ubuntu-512mb-sfo1-01:/var/lib/dokku/plugins# dokku postgres:link DATABASE ubuntu-512mb-sfo1-01
2016/02/18 05:24:38 open /var/lib/dokku/plugins/available/pg-plugin/plugin.toml: no such file or directory
2016/02/18 05:24:38 open /var/lib/dokku/plugins/available/pg-plugin/plugin.toml: no such file or directory
no config vars for ubuntu-512mb-sfo1-01
Can someone help me? I try to deploy rails to digital ocean.
I use http://blog.flatironschool.com/using-digital-ocean-and-dokku-for-easier-rails-app-deploys/ - this tutorial but it seems to be horribly outdated. I ran into so many errors so I am thinking of giving this up and staying with heroku hosting.
It means that you don't have a Postgres docker container active. Take a look at the dokku-pg-pluging to know how to configure and instantiate a postgres docker container.
By the way, since your objective is to change from Heroku to DigitalOcean, and you're having trouble using dokku, may I suggest you using deploy bot instead? I did managed to successfully deploy an rails 4 app to DigitalOcean using deploy bot. Follow this tutorial. And you can easily follow this guide with deploy bot, adapting the unicorn and nginx stop/start services with the hooks that deploy bot provides.
Edit:
Since you wanted a more specific answer for the deploy bot solution, here goes my approach (this was +/- 3/4 months ago):
Create the droplet and follow the guide to create a droplet, install ruby, rails, unicorn and nginx and the script to control unicorn (it's in the tutorial).
Configure the deploy bot and make sure you run bundle install and another rails' specific commands (changing environments and so on) after the upload (this is a predefined hook).
The last command should be service nginx restart to restart the server (using the script from step 1).
Profit!

Ruby on Rails application deployment on local computer with postgresql

I am new to Ruby on Rails. We have developed an small application with Postgresql. Now we have to deploy it. But when i searched over internet i found lot of suggestion is to deploy them on Heroku or some premium servers. where we are not in a position now to deploy it on cloud.
How can i deploy the application on local computer? Is this similar to setting up a development environment?
Any link or lead will be much appreciated!
I hope you have your application already running on your development environment.
Create another database in your postgres, to use it for production in local system. And make necessary changes in database.yml
I feel passenger is the easiest way to deploy application, you can follow the steps in this link https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04 to deploy your app.
Heroku also have free deployment for few application. You can use heroku.
There are some more option like AWS, Digital Ocean. AWS is also free for one year.
Yes setting up a development environment is like set up your environment. But best practice is use a deployment automation like capistrano.
You can run it in a production environment and make it public. I had written a blog post regarding this.
Please check here
ps - Make sure your system is up for public access and i am hoping that this is for test purpose only and to show it to your clients.
Yes, it would be fairly similar to setting up your development environment.
In addition to setting up Passenger as described in the Digital Ocean post from Rajuk's answer, I use Capistrano for deployment to my Ubuntu servers. You can set up the Capistrano deployment configuration to deploy to any machine.
The possible configuration variables are too numerous to address here without further details about your specific situation.
Check out Railscast #335 Deploying to a VPS where Ryan talks about deploying to a Linux machine (a cloud VPS in this case) with Capistrano.

Can Rails be deployed locally? without using git

I have made an app with the use of Git and Heroku.
I'm curious if i can deploy Ruby on Rails locally without using Git.
If you aren't going to deploy to Heroku, you don't technically need Git at all. Just delete the .git folder. Given that Git is a great tool however, doing this is a bad idea.
You can deploy a Rails app locally, and the typical way to do this is with Apache and Passenger ( I'm assuming you are using a flavor of linux, OSX may have a host running already ).
It has been a while since I had done this, but this page seems to have the right idea:
https://nathanhoad.net/how-to-ruby-on-rails-ubuntu-apache-with-passenger
Rails s or rails server (in terminal) and you have localhost:3000. This is your local rails program and is incredibly convienent for development. Of course you need to be in the directory of your program to deploy it on localhost

Creating and deploying new Heroku applications with a Rails application hosted on Heroku

I have a rails application running on heroku. I would like to make that application to create & deploy other applications on heroku.
Since the Cedar stack allows writing to the filesystem I can generate the files needed for the new application. My question is how to issue the "heroku create" and "git push heroku master" commands for deployment.
Is there any gems out there / can I use the heroku CLI in heroku together with the ruby system call?
You can do everything that you need to do Heroku wise with the Heroku gem. Bear in mind though that this will need credentials to authenticate, so you'll need to be happy with storing these in the applications config.
From a git point of view, use ruby-git.
It's probably worth looking at making whatever it is you're making multi-tenanted so you don't have to worry about this problem, and also won't have to worry about hundreds of applications to maintain (updates, bugfixes and the like)

Restarting Rails Application

I am building an application that will only be run on a local network and am looking for the best way to restart my server from within the application itself. For the time being this is only running on Windows using WEBrick.
Look at Capistrano as others have suggested, it's fantastic :)
$ cap deploy
That's all you have to do. It'll grab the latest source from your git/SVN repo (lots more supported ofc), deploy, and restart your app server.

Resources