Docker compose env variables within meteor settings


#1

Hello.

At the moment I am building a nodejs app out of meteor (meteor build) and running it from within a docker. I pass the meteor specific env vars in the docker-compose.yml like below:

...
...
environment:
      - NODE_ENV=production
      - PORT=9000
      - ROOT_URL=http://127.0.0.1
      - MONGO_URL=mongodb://mongodb:27017/claynet
      - 'METEOR_SETTINGS={"public": {"ipAddress: "10.10.10.10"}}'
...
...

Here lies the problem. When I export the IP address field as is, everything works. But more often than not, I will not be aware of the ipaddress prior to deployement. I could run a shell script that could export the ipaddress each time. This works in the case of a normal node process.evn like so:

..
environment:
   - ipAddress=${ipAddressFromExport}
..

However, the same ${...} cannot be used from within the METEOR_SETTINGS JSON object.

Is there any workaround for this?

Thanks.


#2

I may be wrong but should it not be:

  • METEOR_SETTINGS=’{“public”: {"ipAddress: “10.10.10.10”}}’

The single quote is maybe in the wrong place. I’m not sure if you need the single quote at all. I do know that sometimes single quotes prevent variable substitution so if the bit after the equals requires quoting, try using double quotes and backslashing all the internal double quotes in the json.