Deploying the application to two different servers with different production.rb content

I am deploying my application with capistrano to two different production servers , but I need to change the content in production.rb

for each server. p>

2 Possible ways that I know.

I feel like they are a bit heavy to change multiple lines.

  • Using different branches (git) for each. - Concerned about the service.

  • Creating a different environment.

How to cope with this situation, is it easier to choose one or a new way?

Rails 3 and Cap 2

Edit : I was also suggested to Use ENV variables or include the file elsewhere on the server

+3


source to share


1 answer


Using different branches (git) for each.

Do it like this if and only if:

  • You want each of the server applications to have noticeably different features, and the features interfere with each other, that is, there is no easy way to use a server-specific feature flag.

  • For example, if one server is an alpha test for new code and one server is a beta test for new code.

Creating a different environment.

Do it like this if and only if:

  • You want each of the server applications to have a noticeably different experience.

  • For example, if one server is a trade show demo server and thus gets wiped down frequently, and one server is your real customer site.



Use ENV Variables

This is the best way.

Use gem dotenv or similar figaro gem .

"dotenv solves the problems of setting up the vars project environment and it's very easy to get started. Start by putting the dotenv-rails ,: groups => [: development ,: test] gems in the appropriate groups, in this case development and test. Then you can put your confidential information to a .env file in your project root directory "

"Figaro is like dotenv. It allows you to store all your secret secrets in a YAML file in config / application.yml. With a simple figaro install command, you automatically add your YAML file to gitignore. Figaro is built to be deployable to Heroku. Convenient configuration, allows you to set values ​​from a configuration file, and also provides useful information about deploying to other hosts.

Credit: Managing Environment Configuration in Rails

+1


source







All Articles