0
votes

I am trying to deploy my LoopBack/Node.js app through a toolchain on Bluemix. I am trying to make use of VCAP_SERVICES in my datasources.production.js file. My issues seem to be related to not getting access to any environment variables during deploy.

I can see in the log output during deploy that NODE_ENV is getting set, but LoopBack loads my datasources.local.js file and not the production one. And my console.log of NODE_ENV says undefined. Any my console.log of JSON.parse(process.env.VCAP_SERVICES) results in {}.

I can also see in the Bluemix UI that I have VCAP_SERVICES bound to my app.

I keep amending this commit but you can see what I am trying to do here, including the console.log calls. https://github.com/StrongLoop-Evangelists/band-app/commit/95640d3ffc7cd9e7553062f7a1b8c66ef0fc2815

And here is the relevant console.log output:

2017-05-08T15:38:22.67+0000 [APP/0]      OUT ---datasources.local.js---
2017-05-08T15:38:22.67+0000 [APP/0]      OUT ---env.js---
2017-05-08T15:38:22.67+0000 [APP/0]      OUT in VCAP if check
2017-05-08T15:38:22.67+0000 [APP/0]      OUT VCAP:  {}
2017-05-08T15:38:22.67+0000 [APP/0]      ERR console.log('NODE_ENV: ', NODE_ENV);
2017-05-08T15:38:22.67+0000 [APP/0]      ERR                           ^
2017-05-08T15:38:22.67+0000 [APP/0]      ERR ReferenceError: NODE_ENV is not defined
2

2 Answers

1
votes

Joe: If you're using the delivery pipeline as part of the toolchain in Bluemix to deploy a cloud foundry app there is one small thing to know.

Setting the "Environment Properties" on a stage will not automatically pass this to the cf app. It only makes them available to the pipeline doing the deployment. To also set these on the cf app, you need to do a cf set-env. For example:

cf set-env myApp $MY_ENV_VAR
0
votes

My issue was manifest.yml related.

This was failing me:

---
applications:
  - name: Band-App
    memory: 256M
  - services:
    - bandapp-cloudantdb

This worked:

name: Band-App
memory: 256M
services:
  - bandapp-cloudantdb