Buildpack read config
Pergunta
im trying to read Grails environment for war build from heroku application config, is that possible, in that case how to do it? is it set in an ENV variable ?
Solução
No, this is not possible. Buildpacks run independently of the configuration. (To convince yourself of this, run heroku config:set
and watch the output: there's no slug compiler.) This is consistent with the 12-Factor App's Build, Release, Run aspect, which strictly separates building (the slug compiler and buildpack), releasing (attaching a build to its configuration), and running (spinning up dynos for a given release).
The usual solution is to have your buildpack emit files that reads the environment and acts appropriately at runtime. For example, Rails reads database configuration from config/database.yml
, while Heroku specifies this in ENV['DATABASE_URL']
. Thus, the buildpack generates a file using this template which causes Rails to use the database specified in the config, allowing the configuration to change without re-building the entire application.