-
Notifications
You must be signed in to change notification settings - Fork 379
Support for env variables ending with _FILE #166
Conversation
Any comment/news about this PR? |
@efrecon I haven't had a chance to look at it properly yet but I'll take a look tomorrow. Thanks for reminding me. |
@DanCech any thoughts regarding this PR? Seems like a good addition to me. |
The concept is an interesting one, the code can be simplified to: for VAR_NAME in $(env | grep '^GF_[^=]\+_FILE=.\+' | sed -r "s/([^=]*)_FILE=.*/\1/g"); do
VAR_NAME_FILE="$VAR_NAME"_FILE
if [ "${!VAR_NAME}" ]; then
echo >&2 "ERROR: Both $VAR_NAME and $VAR_NAME_FILE are set (but are exclusive)"
exit 1
fi
echo "Getting secret $VAR_NAME from ${!VAR_NAME_FILE}"
export "$VAR_NAME"="$(< "${!VAR_NAME_FILE}")"
unset "$VAR_NAME_FILE"
done |
Fine by me, do you want to take in the PR and make the change manually afterwards? |
I committed the tweaked version, @efrecon can you confirm that the updated code works for you? |
Thanks guys! Merging this now! |
This ought to be documented somewhere. The README from this repo is automatically copied onto the Docker hub and basically points out the general documentation on the Grafana main site. A new sub-section under the docker installation documentation perhaps? Maybe I am blind, but I can't seem to find the section on Docker under the grafana.org project. Where is the source for the documentation? (sorry...) |
@efrecon Definitely. There's an issue in the main repo grafana/grafana#12132 to track that need. If you feel up for it you're more than welcome to, otherwise I'll make sure it happens before the 5.2 release. This file needs to be updated: docker.md All documentation pertaining to running Grafana as a Docker container sits in the install instruction you linked to. We keep the bare minimum in the README.md here and on Docker Hub. |
@efrecon it looks like we'll be doing a beta release very soon so I'll write up the docs myself. Thanks anyway. |
Feel free to pick anything (or nothing) from here if necessary. |
@efrecon Thanks for sharing your post. |
This slight modification to the main run script will recognise environment variables starting with
GF_
and ending with_FILE
. Whenever such variables exist, the content of the file that they point at will be read and used to set the same environment variable, but without the_FILE
ending. This is handy when using Docker secrets and solves #149 . The use of the ending_FILE
is inspired by other official images, such as postgres for example.