forked from swisscom/docs-appcloud-tutorial-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.html.md.erb
35 lines (26 loc) · 1.34 KB
/
environment.html.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---
title: Define Environment Variables
owner: Tobias Fuhrimann
---
<strong><%= modified_date %></strong>
<%= vars.product_short %> lets you externalize configuration - storing data such as encryption keys or external resource addresses in <a href="../devguide/deploy-apps/environment-variable.html" target="_blank">environment variables</a>.
At runtime, environment variables are exposed to the application through its environment. You can use these for example to run Node.js in production mode setting the `NODE_ENV` environment variable.
<pre class="terminal">
$ cf set-env my-nodejs-app NODE_ENV production
Setting env variable 'NODE_ENV' to 'production' for app my-nodejs-app in org MyOrg / space MySpace as [email protected]...
OK
TIP: Use 'cf restage' to ensure your env variable changes take effect
</pre>
Then restage your app as suggested using
<pre class="terminal">
$ cf restage my-nodejs-app
Restaging app my-nodejs-app in org MyOrg / space MySpace as [email protected]...
-----> Downloaded app package (8.0K)
-----> Downloaded app buildpack cache (2.3M)
-------> Buildpack version 1.5.8
...
</pre>
All environment variables are accessed using the `process.env` namespace from within your Node.js app.
<div style="text-align:center;margin:3em;">
<a href="./bind-service.html" class="btn btn-primary">I've set my environment variable</a>
</div>