Define Environment Variables

Page last updated:

Page last updated:

Cloud Foundry lets you externalize configuration - storing data such as encryption keys or external resource addresses in environment variables.

At runtime, environment variables are exposed to the application through its environment. You can use these for example to run your App in production mode setting the RACK_ENV environment variable.

$ cf set-env my-ruby-app RACK_ENV production
Setting env variable 'RACK_ENV' to 'production' for app my-ruby-app in org MyOrg / space MySpace as user@smydomain.com...
OK
TIP: Use 'cf restage' to ensure your env variable changes take effect

Then restage your app as suggested using

$ cf restage my-ruby-app
Restaging app my-ruby-app in org MyOrg / space MySpace as user@mydomain.com...
-----> Downloaded app package (8.0K)
-----> Downloaded app buildpack cache (2.3M)
-------> Buildpack version 1.6.14

...

All environment variables are accessed using ENV['MY_VARIABLE'] from within your Ruby app.

I’ve set my environment variable
View the source for this page in GitHub