Skip to content

Instantly share code, notes, and snippets.

@miguelemosreverte
Created May 17, 2018 20:10
Show Gist options
  • Save miguelemosreverte/011d24dbf37dc7375399b38bdcaf2933 to your computer and use it in GitHub Desktop.
Save miguelemosreverte/011d24dbf37dc7375399b38bdcaf2933 to your computer and use it in GitHub Desktop.
I wanted for the server to run on DEV or PROD enviroments seammesly.
For that it was necessary for it to know which enviroment it was running on.
And that could be done in many ways, being a modification to the Dockerfile the most elegant.
Now since 3:46 PM I have been dealing with this bug, mainly because each time I make a change I need to rebuild the docker image.
Forum posts like this one https://imgur.com/a/YuRiIRO
seem to suggest that adding lines like this to Dockerfile
# Environment Variables
ENV iamIP2="10.118.225.199"
ENV iamPort 9999
ENV iamPort2=9997
should make JS code like this work:
console.log(process.env.iamIP2) // "10.118.225.199"
console.log(process.env.iamPort) // 9999
console.log(process.env.iamPort2) // 9997
It does not. This is the result it gives.
https://i.imgur.com/GXPbQhC.png
I will add to the spreadsheet this feature as a free one, because of the time it demanded
and because I did it as a perfeccionist. I would not, ever, add the info to the code itself.
@miguelemosreverte
Copy link
Author

@miguelemosreverte
Copy link
Author

Fixed like THIS
https://imgur.com/a/vPvlByk

@miguelemosreverte
Copy link
Author

miguelemosreverte commented May 18, 2018

TL;DR
React was sanitizing my enviroment variables, leaving only the ones that start with REACT_APP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment