Docker and Meteor, defining settings without settings.json. Programmatically.

Recentily I’ve been playing a little bit with Docker and Meteor, at the beginning, everything was ok but as soon I started to use settings.json file to define properties I started to face some issues, Node complaints about the JSON structure and Docker complaints about the syntax.

Problem with node

In my host machine, Meteor was parsing and using settings.xml without any problems as usual.

But after building the application and trying to start it with Node I got a beautiful “METEOR_SETTINGS are not valid JSON”. What? Yes, the common solution for it just passes the settings.json direct to METEOR_SETTINGS what is correct, it expects a JSON not a path so, doing this would solve the problem.

Ok, problem solved right? Not so fast my friend.

Problem with Docker

With that information in my hand, I basically put that snippet in my docker-compose.yml like that.

All right! That’s it! Nope.

Now Docker didn’t like “$ at the end of environment variable causes “Invalid Interpolation” error”. Ok, it’s documented, if we have to use $, we need to escape it, using another $ in front of it.

It worked! Docker accepted that! But was not good for Node, now METEOR_SETTINGS has $(cat /bundle/settings.json) as value, definitely not what I needed.

I tried using { instead of (, tried “, ” with (, ” with {, one $, two $, so on and nothing.

The Solution

Is it possible to use the same JSON format, but without using the settings.json file, just set it programmatically. Using underscore.js defaults to doing it, you’ll not even have to change anything in the properties structure.


Meteor working as usual without any weird workaround on top of it, just an alternative to save some hours or prevent you from using some fancy 3rdparty plugin that has nothing to do with your project.



Leave a Reply