0

I have an application that must be run in three different environments, called dev, beta and prod.

I created three different applications on heroku, so all the environments can be run at the same time, and I deploy the code from the right git repo to the right application when I need to. I think that it is a completely normal situation :-)

I have a branch on git for dev purpose, when I need, I branch a beta version to deploy on beta, when it is ready, I deploy on prod and merge back to the trunk, following this branching model

I would like to add the New Relic monitoring system, as an Heroku add-on, only to one of the application, the production one. To install New Relic, you have to include a gem in the Gemfile, so I need to include the gem only for production Gemfile.

Given that the current stack on Heroku does not support the groups in the Gemfile, how can I achieve this goal? Should I have to manage by hand each gem file before bringing to production?

EDIT

To better clafify what I tried, maybe I am missing something obvious:

I added

group :production do
   gem 'newrelic_rpm'
end

to Gemfile. My dev environment has RACK_ENV and RAILS_ENV set to development, when I push to heroku the application is deployed with the newrelic gem.

emas
  • 668
  • 8
  • 17

2 Answers2

0

Given that the current stack on Heroku does not support the groups in the Gemfile

I don't believe this to be an accurate statement.

group :production do
  gem 'some_production_gem'
end

Will only install some_production_gem in the production environment. Use RACK_ENV and RAILS_ENV env vars for your separate applications to manage that. I believe group :staging would work the same, if you specified RAILS_ENV: staging in your Heroku environment variables.

catsby
  • 11,276
  • 3
  • 37
  • 37
  • 1
    Thanks for the reply, but as I found on https://devcenter.heroku.com/articles/bundler#specifying-gems-and-groups "Please note - for the time being, the Cedar stack does not support BUNDLE_WITHOUT." So, also if I specify the gem with the group statement, this doesn't matter at all, heroku will bring the gem also in my dev or staging or whatever environment. I tried with New Relic, and immediately my app on development environment was carefully monitored :-). But maybe I miss something... – emas May 18 '13 at 18:56
0

From https://devcenter.heroku.com/articles/bundler#specifying-gems-and-groups ...

If you would like to use BUNDLE_WITHOUT on cedar, you need to enable the user-env-compile feature flag. After enabling the feature flag, you can exclude certain groups from being installed by using the BUNDLE_WITHOUT config var:

$ heroku config:set BUNDLE_WITHOUT="development:test"

From https://devcenter.heroku.com/articles/labs-user-env-compile#enabling ...

To enable the feature:

$ heroku labs:enable user-env-compile -a myapp

A note from Heroku's security:

The use of the user-env-compile feature is discouraged because it writes your config vars into the slug in plaintext.

user664833
  • 18,397
  • 19
  • 91
  • 140