Windows: docker or node run and refer to settings.json file


#1

hi all,

using windows, I tried everything.




http://ericterpstra.com/2016/01/meteor-on-windows-my-experience-so-far/ --> the powershell script does not work, I get

But how do I refer to my MULTI LINE settings.json file when I start node? it must be so simple…

thank you so much!

docker run --rm -e ROOT_URL=http://localhost -e METEOR_SETTINGS='NOT VALID JSON ERROR' -e MONGO_URL=mongodb://172.17.0.2 -p 8080:80 yourname/app

Example settings.json file

{
    "adminEmails": "dfdsafd@df.com",
    "public": {
        "host": "PRESALES1",
        "port": 81, 
        "UDC": "OEM_HOST", 
        "virtualProxyClientUsage": "meteor",                       
        "webIntegrationHost": "localhost",
        "webIntegrationDemoPort": 3030,
        "facebook":{
            "clientId": "dfdf"         
        },
        "templateAppId": "5658d4a5-0102-4b74-9c5d-1b01c2430c8f"                        
    },
    "private": {
        "host": "PRESALES1",
        "port": 81, 
        "certificatesDirectory": "C:\\Repository\\Exported Certificates\\.Local Certificates",
        "notificationURL": "http://nlsch-mbj3:3000/updateSenseInfo",
        "SenseServerInternalLanIP": "PRESALES1",        
        "useSSL": false,
        "passphrase": null,
        "authentication": "header",
        "virtualProxy": "hdr",
        "headerKey": "hdr-usr",
        "UDC": "OEM_HOST",        
        "headerValue": "PRESALES1\\meteor",        
        "isSecure": true,
        "engineHeaders": "UserDirectory=PRESALES1;UserId=Qlik",
        "enginePort": 4747,
        "proxyPort": 4243,
        "google":{
            "clientId": "df-df.apps.googleusercontent.com",
            "secret": "YCP43OPc_-df-o-hbu1"
        },
        "facebook":{
            "clientId": "df",
            "secret": "df"
        }
    }
}

Thank you so much!


#2

If I try an empty object {}, it continues the execution, but it can then not find my settings variables (off course)

So, how can I put valid JSON in? (I have this in my settings.json file using windows 10)

thanks


#3

I’m almost certain that the last time I tried passing quoted JSON in cmd.exe it failed because of the surrounding single quotes. I think I had to remove all white space and newlines and pass an unquoted single line of JSON.

I may have remembered wrongly, but may be worth trying:

{"adminEmails": "dfdsafd@df.com","public": {"host": "PRESALES1","port": 81,"UDC": "OEM_HOST","virtualProxyClientUsage": "meteor","webIntegrationHost": "localhost","webIntegrationDemoPort": 3030,"facebook":{"clientId": "dfdf"},"templateAppId": "5658d4a5-0102-4b74-9c5d-1b01c2430c8f"},"private": {"host": "PRESALES1","port": 81,"certificatesDirectory": "C:\\Repository\\Exported Certificates\\.Local Certificates","notificationURL": "http://nlsch-mbj3:3000/updateSenseInfo","SenseServerInternalLanIP": "PRESALES1","useSSL": false,"passphrase": null,"authentication": "header","virtualProxy": "hdr","headerKey": "hdr-usr","UDC": "OEM_HOST","headerValue": "PRESALES1\\meteor","isSecure": true,"engineHeaders": "UserDirectory=PRESALES1;UserId=Qlik","enginePort": 4747,"proxyPort": 4243,"google":{"clientId": "df-df.apps.googleusercontent.com","secret": "YCP43OPc_-df-o-hbu1"},"facebook":{"clientId": "df","secret": "df"}}}

#4

Thanks, but then it says

C:\Users\mbj\Documents\GitHub\QRSMeteor>"docker image run.bat"

C:\Users\mbj\Documents\GitHub\QRSMeteor>docker run --rm -e ROOT_URL=http://localhost -e METEOR_SETTINGS={"adminEmails": "dfdsafd@df.com","public": {"host": "PRESALES1","port": 81,"UDC": "OEM_HOST","virtualProxyClientUsage": "meteor","webIntegrationHost": "localhost","webIntegrationDemoPort": 3030,"facebook":{"clientId": "dfdf"},"templateAppId": "5658d4a5-0102-4b74-9c5d-1b01c2430c8f"},"private": {"host": "PRESALES1","port": 81,"certificatesDirectory": "C:\\Repository\\Exported Certificates\\.Local Certificates","notificationURL": "http://nlsch-mbj3:3000/updateSenseInfo","SenseServerInternalLanIP": "PRESALES1","useSSL": false,"passphrase": null,"authentication": "header","virtualProxy": "hdr","headerKey": "hdr-usr","UDC": "OEM_HOST","headerValue": "PRESALES1\\meteor","isSecure": true,"engineHeaders": "UserDirectory=PRESALES1;UserId=Qlik","enginePort": 4747,"proxyPort": 4243,"google":{"clientId": "df-df.apps.googleusercontent.com","secret": "YCP43OPc_-df-o-hbu1"},"facebook":{"clientId": "df","secret": "df"}}} -e MONGO_URL=mongodb://172.17.0.2 -p 8080:80 yourname/app
docker: Error parsing reference: "dfdsafd@df.com,public:" is not a valid repository/tag.
See 'docker run --help'.

So It kinda looks inside my settings file :). Docker reads the json, it stead of just swallowing it as environment var… (it is the first attribute value pair it breaks on)


#5

My bad - I left some spaces in that line. Try this:

{"adminEmails":"dfdsafd@df.com","public":{"host":"PRESALES1","port":81,"UDC":"OEM_HOST","virtualProxyClientUsage":"meteor","webIntegrationHost":"localhost","webIntegrationDemoPort":3030,"facebook":{"clientId":"dfdf"},"templateAppId":"5658d4a5-0102-4b74-9c5d-1b01c2430c8f"},"private":{"host":"PRESALES1","port":81,"certificatesDirectory":"C:\Repository\Exported Certificates\.Local Certificates","notificationURL":"http://nlsch-mbj3:3000/updateSenseInfo","SenseServerInternalLanIP":"PRESALES1","useSSL":false,"passphrase":null,"authentication":"header","virtualProxy":"hdr","headerKey":"hdr-usr","UDC":"OEM_HOST","headerValue":"PRESALES1\meteor","isSecure":true,"engineHeaders":"UserDirectory=PRESALES1;UserId=Qlik","enginePort":4747,"proxyPort":4243,"google":{"clientId":"df-df.apps.googleusercontent.com","secret":"YCP43OPc_-df-o-hbu1"},"facebook":{"clientId":"df","secret":"df"}}}

#6

Thanks, it would be even better if I can just refer to the json file, is that possible in windows?
in linux it is like this - METEOR_SETTINGS=$cat(settings.json)

ps, with your solution I get

Error: METEOR_SETTINGS are not valid JSON: {adminEmails:dfdsafd@df.com,public:{host:PRESALES1,port:81,UDC:OEM_HOST,virtualProxyClientUsage:meteor,webIntegrationHost:localhost,webIntegrationDemoPort:3030,facebook:{clientId:dfdf},templateAppId:5658d4a5-0102-4b74-9c5d-1b01c2430c8f},private:{host:PRESALES1,port:81,certificatesDirectory:C:\Repository\Exported Certificates\.Local Certificates,notificationURL:http://nlsch-mbj3:3000/updateSenseInfo,SenseServerInternalLanIP:PRESALES1,useSSL:false,passphrase:null,authentication:header,virtualProxy:hdr,headerKey:hdr-usr,UDC:OEM_HOST,headerValue:PRESALES1\meteor,isSecure:true,engineHeaders:UserDirectory=PRESALES1;UserId=Qlik,enginePort:4747,proxyPort:4243,google:{clientId:df-df.apps.googleusercontent.com,secret:YCP43OPc_-df-o-hbu1},facebook:{clientId:df,secret:df}}}
    at packages/meteor/server_environment.js:24:1
    at packages/meteor/server_environment.js:41:1
    at /output/bundle/programs/server/packages/meteor.js:1365:3
    at /output/bundle/programs/server/boot.js:292:10
    at Array.forEach (native)
    at Function._.each._.forEach (/output/bundle/programs/server/node_modules/underscore/underscore.js:79:11)
    at /output/bundle/programs/server/boot.js:128:5

C:\Users\mbj\Documents\GitHub\QRSMeteor>

With all my tests I get this, even with simple example json files…


#7

Hmm. It’s been a long time since I tried that in Windows, so I guess I’ve just forgotten what I did to make it work. Really don’t know if you can embed a file like that in Windows.


#8

Google says to enclose the string in single quotes and escape the inner quotes. Which gives this:

"{\"adminEmails\":\"dfdsafd@df.com\",\"public\":{\"host\":\"PRESALES1\",\"port\":81,\"UDC\":\"OEM_HOST\",\"virtualProxyClientUsage\":\"meteor\",\"webIntegrationHost\":\"localhost\",\"webIntegrationDemoPort\":3030,\"facebook\":{\"clientId\":\"dfdf\"},\"templateAppId\":\"5658d4a5-0102-4b74-9c5d-1b01c2430c8f\"},\"private\":{\"host\":\"PRESALES1\",\"port\":81,\"certificatesDirectory\":\"C:\Repository\Exported Certificates\.Local Certificates\",\"notificationURL\":\"http://nlsch-mbj3:3000/updateSenseInfo\",\"SenseServerInternalLanIP\":\"PRESALES1\",\"useSSL\":false,\"passphrase\":null,\"authentication\":\"header\",\"virtualProxy\":\"hdr\",\"headerKey\":\"hdr-usr\",\"UDC\":\"OEM_HOST\",\"headerValue\":\"PRESALES1\meteor\",\"isSecure\":true,\"engineHeaders\":\"UserDirectory=PRESALES1;UserId=Qlik\",\"enginePort\":4747,\"proxyPort\":4243,\"google\":{\"clientId\":\"df-df.apps.googleusercontent.com\",\"secret\":\"YCP43OPc_-df-o-hbu1\"},\"facebook\":{\"clientId\":\"df\",\"secret\":\"df\"}}}"

Pretty horrible.


#9

thanks, man, but deploying meteor on windows is terrible…

now I get

C:\Users\mbj\Documents\GitHub\QRSMeteor>"docker image run.bat"

C:\Users\mbj\Documents\GitHub\QRSMeteor>docker run --rm -e ROOT_URL=http://localhost -e METEOR_SETTINGS={\"adminEmails\":\"dfdsafd@df.com\",\"public\":{\"host\":\"PRESALES1\",\"port\":81,\"UDC\":\"OEM_HOST\",\"virtualProxyClientUsage\":\"meteor\",\"webIntegrationHost\":\"localhost\",\"webIntegrationDemoPort\":3030,\"facebook\":{\"clientId\":\"dfdf\"},\"templateAppId\":\"5658d4a5-0102-4b74-9c5d-1b01c2430c8f\"},\"private\":{\"host\":\"PRESALES1\",\"port\":81,\"certificatesDirectory\":\"C:\Repository\Exported Certificates\.Local Certificates\",\"notificationURL\":\"http://nlsch-mbj3:3000/updateSenseInfo\",\"SenseServerInternalLanIP\":\"PRESALES1\",\"useSSL\":false,\"passphrase\":null,\"authentication\":\"header\",\"virtualProxy\":\"hdr\",\"headerKey\":\"hdr-usr\",\"UDC\":\"OEM_HOST\",\"headerValue\":\"PRESALES1\meteor\",\"isSecure\":true,\"engineHeaders\":\"UserDirectory=PRESALES1;UserId=Qlik\",\"enginePort\":4747,\"proxyPort\":4243,\"google\":{\"clientId\":\"df-df.apps.googleusercontent.com\",\"secret\":\"YCP43OPc_-df-o-hbu1\"},\"facebook\":{\"clientId\":\"df\",\"secret\":\"df\"}}} -e MONGO_URL=mongodb://172.17.0.2 -p 8080:80 yourname/app
docker: Error parsing reference: "Certificates\\.Local" is not a valid repository/tag.
See 'docker run --help'.

C:\Users\mbj\Documents\GitHub\QRSMeteor>"docker image run.bat"

C:\Users\mbj\Documents\GitHub\QRSMeteor>docker run --rm -e ROOT_URL=http://localhost -e METEOR_SETTINGS='{\"adminEmails\":\"dfdsafd@df.com\",\"public\":{\"host\":\"PRESALES1\",\"port\":81,\"UDC\":\"OEM_HOST\",\"virtualProxyClientUsage\":\"meteor\",\"webIntegrationHost\":\"localhost\",\"webIntegrationDemoPort\":3030,\"facebook\":{\"clientId\":\"dfdf\"},\"templateAppId\":\"5658d4a5-0102-4b74-9c5d-1b01c2430c8f\"},\"private\":{\"host\":\"PRESALES1\",\"port\":81,\"certificatesDirectory\":\"C:\Repository\Exported Certificates\.Local Certificates\",\"notificationURL\":\"http://nlsch-mbj3:3000/updateSenseInfo\",\"SenseServerInternalLanIP\":\"PRESALES1\",\"useSSL\":false,\"passphrase\":null,\"authentication\":\"header\",\"virtualProxy\":\"hdr\",\"headerKey\":\"hdr-usr\",\"UDC\":\"OEM_HOST\",\"headerValue\":\"PRESALES1\meteor\",\"isSecure\":true,\"engineHeaders\":\"UserDirectory=PRESALES1;UserId=Qlik\",\"enginePort\":4747,\"proxyPort\":4243,\"google\":{\"clientId\":\"df-df.apps.googleusercontent.com\",\"secret\":\"YCP43OPc_-df-o-hbu1\"},\"facebook\":{\"clientId\":\"df\",\"secret\":\"df\"}}}' -e MONGO_URL=mongodb://172.17.0.2 -p 8080:80 yourname/app
docker: Error parsing reference: "Certificates\\.Local" is not a valid repository/tag.
See 'docker run --help'.

C:\Users\mbj\Documents\GitHub\QRSMeteor>"docker image run.bat"

C:\Users\mbj\Documents\GitHub\QRSMeteor>docker run --rm -e ROOT_URL=http://localhost -e METEOR_SETTINGS='{\"adminEmails\":\"dfdsafd@df.com\",\"public\":{\"host\":\"PRESALES1\",\"port\":81,\"UDC\":\"OEM_HOST\",\"virtualProxyClientUsage\":\"meteor\",\"webIntegrationHost\":\"localhost\",\"webIntegrationDemoPort\":3030,\"facebook\":{\"clientId\":\"dfdf\"},\"templateAppId\":\"5658d4a5-0102-4b74-9c5d-1b01c2430c8f\"},\"private\":{\"host\":\"PRESALES1\",\"port\":81,\"certificatesDirectory\":\"C:\\Repository\\Exported Certificates\\.Local Certificates\",\"notificationURL\":\"http://nlsch-mbj3:3000/updateSenseInfo\",\"SenseServerInternalLanIP\":\"PRESALES1\",\"useSSL\":false,\"passphrase\":null,\"authentication\":\"header\",\"virtualProxy\":\"hdr\",\"headerKey\":\"hdr-usr\",\"UDC\":\"OEM_HOST\",\"headerValue\":\"PRESALES1\meteor\",\"isSecure\":true,\"engineHeaders\":\"UserDirectory=PRESALES1;UserId=Qlik\",\"enginePort\":4747,\"proxyPort\":4243,\"google\":{\"clientId\":\"df-df.apps.googleusercontent.com\",\"secret\":\"YCP43OPc_-df-o-hbu1\"},\"facebook\":{\"clientId\":\"df\",\"secret\":\"df\"}}}' -e MONGO_URL=mongodb://172.17.0.2 -p 8080:80 yourname/app
docker: Error parsing reference: "Certificates\\\\.Local" is not a valid repository/tag.
See 'docker run --help'.

C:\Users\mbj\Documents\GitHub\QRSMeteor>"docker image run.bat"

C:\Users\mbj\Documents\GitHub\QRSMeteor>docker run --rm -e ROOT_URL=http://localhost -e METEOR_SETTINGS='{\"adminEmails\":\"dfdsafd@df.com\",\"public\":{\"host\":\"PRESALES1\",\"port\":81,\"UDC\":\"OEM_HOST\",\"virtualProxyClientUsage\":\"meteor\",\"webIntegrationHost\":\"localhost\",\"webIntegrationDemoPort\":3030,\"facebook\":{\"clientId\":\"dfdf\"},\"templateAppId\":\"5658d4a5-0102-4b74-9c5d-1b01c2430c8f\"},\"private\":{\"host\":\"PRESALES1\",\"port\":81,\"certificatesDirectory\":\"C:\Repository\Exported Certificates\.Local Certificates\",\"notificationURL\":\"http://nlsch-mbj3:3000/updateSenseInfo\",\"SenseServerInternalLanIP\":\"PRESALES1\",\"useSSL\":false,\"passphrase\":null,\"authentication\":\"header\",\"virtualProxy\":\"hdr\",\"headerKey\":\"hdr-usr\",\"UDC\":\"OEM_HOST\",\"headerValue\":\"PRESALES1\meteor\",\"isSecure\":true,\"engineHeaders\":\"UserDirectory=PRESALES1;UserId=Qlik\",\"enginePort\":4747,\"proxyPort\":4243,\"google\":{\"clientId\":\"df-df.apps.googleusercontent.com\",\"secret\":\"YCP43OPc_-df-o-hbu1\"},\"facebook\":{\"clientId\":\"df\",\"secret\":\"df\"}}}' -e MONGO_URL=mongodb://172.17.0.2 -p 8080:80 yourname/app
docker: Error parsing reference: "Certificates\\.Local" is not a valid repository/tag.
See 'docker run --help'.

#10

Strange I can’t get it to work.

So we just want to pass 1 json file as input for a windows environment variable. I tried this convertor but still the above errors: http://www.freeformatter.com/json-formatter.html#ad-output

Ok, we should not use single quotes around the JSON. This works: ROOT_URL=http://localhost -e METEOR_SETTINGS={\"a\":1} , but is too simple off course…


#11

Yes - no quotes around the entire string seems to be correct.

The other problem you’re seeing is when it’s parsing Windows file paths. These need their single backslashes escaping as \\. Which I think leaves us with:

{\"adminEmails\":\"dfdsafd@df.com\",\"public\":{\"host\":\"PRESALES1\",\"port\":81,\"UDC\":\"OEM_HOST\",\"virtualProxyClientUsage\":\"meteor\",\"webIntegrationHost\":\"localhost\",\"webIntegrationDemoPort\":3030,\"facebook\":{\"clientId\":\"dfdf\"},\"templateAppId\":\"5658d4a5-0102-4b74-9c5d-1b01c2430c8f\"},\"private\":{\"host\":\"PRESALES1\",\"port\":81,\"certificatesDirectory\":\"C:\\Repository\\Exported Certificates\\.Local Certificates\",\"notificationURL\":\"http://nlsch-mbj3:3000/updateSenseInfo\",\"SenseServerInternalLanIP\":\"PRESALES1\",\"useSSL\":false,\"passphrase\":null,\"authentication\":\"header\",\"virtualProxy\":\"hdr\",\"headerKey\":\"hdr-usr\",\"UDC\":\"OEM_HOST\",\"headerValue\":\"PRESALES1\meteor\",\"isSecure\":true,\"engineHeaders\":\"UserDirectory=PRESALES1;UserId=Qlik\",\"enginePort\":4747,\"proxyPort\":4243,\"google\":{\"clientId\":\"df-df.apps.googleusercontent.com\",\"secret\":\"YCP43OPc_-df-o-hbu1\"},\"facebook\":{\"clientId\":\"df\",\"secret\":\"df\"}}}

#12

Why not try one of the other ways to pass environment variables to docker?

For example, this should be another way of setting the environment variable:

  1. Put the settings.json into an environment variable first. This used to work on Command Prompt – not sure about PowerShell:

     set /P METEOR_SETTINGS=< settings.json
    
  2. Then have docker run inherit that variable from the shell, by leaving off the =... part:

docker run --rm -e METEOR_SETTINGS -e ROOT_URL=http://localhost -p 8080:80 yourname/app

Alternatively, docker run supports using an environment file (ala --env-file ./env.list) which is a file of key-value pairs.


To be fair, all of your problems you’ve mentioned here have to do with running docker or typical problems with using the Windows command line.


#13

Oooh. Didn’t know you could do that.


#14

Hi,

Doesn’t it only read the first line?

C:\Users\mbj\Documents\GitHub\QRSMeteor>"docker image run.bat"

C:\Users\mbj\Documents\GitHub\QRSMeteor>set /P METEOR_SETTINGS= 0<test.json

C:\Users\mbj\Documents\GitHub\QRSMeteor>echo %METEOR_SETTINGS%
{

#15

Hmm, not sure how that works when echo-ing, but the full file shows up if you run set METEOR_SETTINGS. I can’t say for certain though (not a reg Windows user), but you might try using the following to see what ENV variables are coming through to the docker container:

docker run -e METEOR_SETTINGS busybox env

#16

If I first make a Windows environment cat… Now I get a “not valid Json” error. If I run set. It looks like Windows truncates my Json file… is there a certain limit

I will look at your other suggested paths.


#17

It’s not truncating your file, the /P switch only reads one line.

You need to parse the json first (e.g using a CLI tool):

npm install -g json
json -0 -f settings.json > temp.txt
SET /P METEOR_SETTINGS=<temp.txt
DEL temp.txt

Load settings.json file in windows environment variable
#18

Hi, yes it is more than just { but I don’t see all if use use the set command. See http://superuser.com/questions/1070272/why-does-windows-have-a-limit-on-environment-variables-at-all

I will try the software cmder so I can use the cat command and pass meteor_settings directly to node


#19

I stand corrected then! I swear that used to work. Must have been a variation of that.

Really, the JSON doesn’t need to be parsed per se, only new-lines removed. If there were an easy way to do that in Windows, that would work as an alternative to json. Anyhow, this seems like a good recommendation.


#20

Thanks

It looks like Windows cuts off after a certain lenght

See https://github.com/QHose/QRSMeteor/blob/master/settings-development%20-%20example.json

Do you know a good tool that converts our Json to a valid string with lines etc?