Open sandrich opened 8 years ago
So basically from what I can find it is not possible to use this image directly as the documentation shows if you want to use settings? I tried the $(cat settings.json) bit with docker run but I get docker errors as it is looking for images from my json settings. Am I missing something?
@zachariahtimothy can you be more specific about what you tried? Turning your settings file into a string and setting that to METEOR_SETTINGS
definitely works (I do it every day), so I assume there's a small misuse or typo somewhere.
I have a simple settings file with the following:
{
"mysql": {
"host": "localhost",
"port": 3306,
"user": "root",
"password": "PASSWORD"
}
}
I am running the container with:
docker run -d \
-e ROOT_URL=http://local.pigknows.com \
-e MONGO_URL=mongodb://local.pigknows.com/pigknows \
-e METEOR_SETTINGS=$(cat settings.json) \
-e STARTUP_DELAY=10 \
-p 80:3000 \
pigknows/pk-webapp
The error I get is "docker: Error parsing reference: "\"mysql\":" is not a valid repository/tag."
Do I need to transform the settings.json file first?
UPDATE: I am a fool. Lol I added quotes around meteor settings and it works! Viola! Final run command:
docker run -d \
-e ROOT_URL=http://local.pigknows.com \
-e MONGO_URL=mongodb://local.pigknows.com/pigknows \
-e METEOR_SETTINGS="$(cat settings.json)" \
-e STARTUP_DELAY=10 \
-p 80:3000 \
pigknows/pk-meteor
Is there a way to specify a file (not a string) that will be used as a settings file?
I am having an issue with this as well. Below you can find my compose file and the error I get back when using it:
# docker-compose.yml
version: '2'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- ROOT_URL=http://wat1node01:3000
- METEOR_SETTINGS="$(cat settings-development.json)"
Error:
ERROR: Invalid interpolation format for "environment" option in service "app": "METEOR_SETTINGS="$(cat settings-development.json)""
Am I just missing something?
@firrae You can do environment variable interpolation in a Docker Compose file now, but you can't execute a command in it (the cat
part).
So you have a few options. You can set that in your local env...
export METEOR_SETTINGS="$(cat path/to/settings.json)"
# either run that before running "docker-compose up"
# or put that in your .bashrc to have it always be available in your shell env
version: '2'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- ROOT_URL=http://wat1node01:3000
- METEOR_SETTINGS
Or you can set it when you run your image(s)...
docker-compose run -e METEOR_SETTINGS="$(cat path/to/settings.json)"
@jshimko I managed to get this to work when I manually exported the env:
# docker-compose.yml
version: '2'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- ROOT_URL=http://wat1node01:3000
- METEOR_SETTINGS=$METEOR_SETTINGS
I will likely continue with this and provide all our servers with the proper env variables or find another solution like the one you posted in dev. In prod I'll likely be using something like Rancher and I'll handle it in their way.
Good to hear.
FYI, you can leave off the =$METEOR_SETTINGS
part. When there's no value assigned, it inherits that variable from your current shell env.
So this is equivalent to your last example
version: '2'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- ROOT_URL=http://wat1node01:3000
- METEOR_SETTINGS
Hu, I never knew that. Thanks.
Hi, I am having issues with METEOR_SETTINGS too but with version: '3' of docker-compose. I have done both options, make the env variable in the shell, If I echo it I can see the contents etc. and giving it in the docker-compose file as an environment variable, but with the same result. I get an error TypeError: Cannot read property 'settings _variable' of undefined. Am I doing anything wrong due to the change of docker-compose version? thanks and best regards.
@aumana If you can provide reproduction steps or a repo that demonstrates this issue, I'd be happy to take a look. Otherwise, I don't know what to recommend without knowing what you've done.
The -e METEOR_SETTINGS="$(cat settings.json)"
trick should be documented for sure!
Documentation pull requests are always welcome @maasha!
Hi
In Kubernetes it would be nice to store settings.json as a secret and have the secret volume mounted into the pod. To solve that I added the following code to my fork entrypoint.sh
Then I mount the secret to /opt/meteor/settings. Example yaml snipped.
Maybe you know better ways to do that. But I think meteor-launchpad should have such an option.