adminMongo
adminMongo copied to clipboard
Environment variables are not used at all
Apparently, if config/app.json already exists, the app ignores all env vars.
This is my Dockerfile that works:
FROM node:latest
COPY . /app/user
WORKDIR /app/user
RUN npm install
+ RUN chmod -R 775 .
+ RUN rm config/app.json
CMD node app.js
Question: Is this the desired behavior? Or should we allow both config sources to co-exist? I prefer the latter, such that env vars may override whatever's in the config file.
I wasted an afternoon debugging this. Thanks @necramirez!
Other people, another workaround for now is docker run -e PASSWORD=password4u mrvauntin/adminmongo /bin/sh -c "rm config/app.json; node app.js".
I can confirm this issue as well, also when I tried @blurrcat solution, it still doesn't load using the variables given. Part of my docker-compose files:
adminmongo:
image: mrvautin/adminmongo:latest
container_name: adminmongo
# command: ['/bin/sh', '-c', '"rm config/app.json; node app.js"'] # I tried this too
networks:
- mongo
ports:
- '8081:1234/tcp'
depends_on:
- mongo
environment:
- CONN_NAME=${mongo_CONN_NAME}
- DB_USERNAME=${mongo_USER}
- DB_PASSWORD=${mongo_PASS}
- DB_HOST=mongo
- DB_PORT=${mongo_PORT}
- DB_NAME=test
- PASSWORD=${adminmongo_PASS}
Old issue but it's still a problem I found a (terrible) workaround to fix auto connection
mongo-admin:
image: mrvautin/adminmongo:latest
ports:
- "1234:1234"
environment:
- CONFIG={"connections":{"dashboard":{"connection_string":"mongodb://db/react_passport","connection_options":{}}}}
- APP={"app":{"host":"0.0.0.0"}}
- HOST=0.0.0.0
command: "/bin/sh -c 'echo $$CONFIG > config/config.json ; echo $$APP > config/app.json ; node app.js'"
restart: always
depends_on:
- db
networks:
dashboard:
I put the JSON that will be parsed for connections directly inside the environment. The $$ escapes the value of the variable, see this stackoverflow post
@mrvautin It should work using a config.json file for handling connections.
@PaulMonnery It does not work for me at the first launching: connections are not automatically read while the configuration files is overwritten at time(I have a configuration folder attached to the container as volume). It seems like a config.json and your command works at the second launching.
In my case it generates the config.json with the correct data, but the UI does not take care of it, so in the UI I don't have got any connection.
A suggestion
- if a config.json exist, use all connections of the config.json (read the file)
- attach if exist environment variables with connection information but don't overwrite the existing config.json
- start server with the dynamic created configuration
In my case it generates the config.json with the correct data, but the UI does not take care of it, so in the UI I don't have got any connection.
A suggestion
- if a config.json exist, use all connections of the config.json (read the file)
- attach if exist environment variables with connection information but don't overwrite the existing config.json
- start server with the dynamic created configuration
Yes, i have to restart my container in order to get the configuration working on.