Monday 8 May 2017

Why isn't my LoopBack/Node app getting environment variables on a toolchain deploy in Bluemix?

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



via joe sepi

No comments:

Post a Comment