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.

meteor --settings settings.json

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.

export METEOR_SETTINGS=$(cat settings.json)

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.

    - MONGO_URL=mongodb://mongo/dashboard
    - ROOT_URL=http://dashboard
    - PORT=3000
    - NODE_ENV=production
    - METEOR_SETTINGS=$(cat /bundle/settings.json)

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.

- METEOR_SETTINGS=$$(cat /bundle/settings.json)

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.startup(function () {
    _.defaults(Meteor.settings, {
        "private": {
            "jira": {

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.


Allan de Queiroz

Allan de Queiroz
London based software engineer

XServer forward from Linux text mode for Headless purposes.

Hello, this post is about XServer forward from Linux text mode, **not ssh forward, anything related to VNC** or things like that.Recently...… Continue reading