2

I have tested a few apps with enable-diego on Bluemix. They all broke because of this change. I could fix most, one I'm still struggling with. And none of which I actually wanted to make code changes in.

Instead of code changes being required to my apps, can I automate the mapping of the variables at container level (or any other solution)?

ralphearle
  • 1,696
  • 13
  • 18
amadain
  • 2,724
  • 4
  • 37
  • 58

1 Answers1

-1

Not tried this but maybe you could create a user provided environment variable and set

VCAP_APP_PORT = $PORT

edit: You can set user-provided environment variables using the Bluemix UI or using the cf set-env command.

Ed Shee
  • 931
  • 1
  • 7
  • 22
  • It's actually VCAP_APP_PORT and it won't let me: Setting env variable 'VCAP_APP_PORT' to '$PORT' for app xx in org xx / space xx as xx... FAILED Server error, status code: 400, error code: 100001, message: The app is invalid: environment_json reserved_key:VCAP_APP_PORT – amadain Dec 13 '16 at 14:18
  • 3
    Ahh, then I'm afraid you'll have to change your code to use PORT instead. Note that the PORT variable works in both DEA and Diego. – Daniel Grim Dec 13 '16 at 14:29
  • Fixed both typos. Shame it didn't work. This is purely conjecture but it might well be that VCAP_APP_PORT is no longer a reserved key once Bluemix transitions to Diego only (and completely away from DEA) – Ed Shee Dec 13 '16 at 15:59
  • Or maybe they'll change their mind and not break all my stuff, someone has asked: https://github.com/cloudfoundry/nsync/pull/16 – amadain Dec 13 '16 at 16:11
  • That would definitely be preferable :D – Ed Shee Dec 13 '16 at 23:18
  • 1
    Have you tried modifying the environment variables in a `.profile.d` script? The `.profile.d` script should run before your application and it shouldn't have any restrictions on what it can do. You should be able to `export VCAP_APP_PORT=$PORT` there and have it visible to your app. It won't require any code changes, but you will need to push your app again. – Daniel Mikusa Dec 14 '16 at 14:54
  • Nice idea but fails in practice also, at staging: 2016-12-15T09:37:58.25+0000 [STG/0] ERR mkdir: cannot create directory '/app/.profile.d': File exists. Odd error actually, it's a file not a directory. – amadain Dec 15 '16 at 09:39
  • Hey Daniel, that actually that worked once I renamed it to .profile! Can you convert to an answer and I'll accept. – amadain Dec 15 '16 at 09:49