-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: major rewrite following grafana/grafana-docker#146
- Loading branch information
Showing
5 changed files
with
134 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ARG GRAFANA_VERSION | ||
|
||
FROM fg2it/grafana-armhf:${GRAFANA_VERSION} | ||
|
||
USER grafana | ||
|
||
ARG GF_INSTALL_PLUGINS="" | ||
|
||
RUN if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then \ | ||
OLDIFS=$IFS; \ | ||
IFS=','; \ | ||
for plugin in ${GF_INSTALL_PLUGINS}; do \ | ||
IFS=$OLDIFS; \ | ||
grafana-cli --pluginsDir "$GF_PATHS_PLUGINS" plugins install ${plugin}; \ | ||
done; \ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,67 @@ | ||
#!/bin/bash -e | ||
|
||
: "${GF_PATHS_CONFIG:=/etc/grafana/grafana.ini}" | ||
: "${GF_PATHS_DATA:=/var/lib/grafana}" | ||
: "${GF_PATHS_LOGS:=/var/log/grafana}" | ||
: "${GF_PATHS_PLUGINS:=/var/lib/grafana/plugins}" | ||
: "${GF_PATHS_PROVISIONING:=/etc/grafana/provisioning}" | ||
PERMISSIONS_OK=0 | ||
|
||
if [ ! -r "$GF_PATHS_CONFIG" ]; then | ||
echo "GF_PATHS_CONFIG='$GF_PATHS_CONFIG' is not readable." | ||
PERMISSIONS_OK=1 | ||
fi | ||
|
||
if [ ! -w "$GF_PATHS_DATA" ]; then | ||
echo "GF_PATHS_DATA='$GF_PATHS_DATA' is not writable." | ||
PERMISSIONS_OK=1 | ||
fi | ||
|
||
if [ ! -r "$GF_PATHS_HOME" ]; then | ||
echo "GF_PATHS_HOME='$GF_PATHS_HOME' is not readable." | ||
PERMISSIONS_OK=1 | ||
fi | ||
|
||
if [ $PERMISSIONS_OK -eq 1 ]; then | ||
echo "You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later" | ||
fi | ||
|
||
if [ ! -d "$GF_PATHS_PLUGINS" ]; then | ||
mkdir "$GF_PATHS_PLUGINS" | ||
fi | ||
|
||
chown -R grafana:grafana "$GF_PATHS_DATA" "$GF_PATHS_LOGS" || true | ||
|
||
if [ ! -z ${GF_AWS_PROFILES+x} ]; then | ||
mkdir -p ~grafana/.aws/ | ||
> ~grafana/.aws/credentials | ||
|
||
for profile in ${GF_AWS_PROFILES}; do | ||
access_key_varname="GF_AWS_${profile}_ACCESS_KEY_ID" | ||
secret_key_varname="GF_AWS_${profile}_SECRET_ACCESS_KEY" | ||
region_varname="GF_AWS_${profile}_REGION" | ||
|
||
if [ ! -z "${!access_key_varname}" -a ! -z "${!secret_key_varname}" ]; then | ||
echo "[${profile}]" >> ~grafana/.aws/credentials | ||
echo "aws_access_key_id = ${!access_key_varname}" >> ~grafana/.aws/credentials | ||
echo "aws_secret_access_key = ${!secret_key_varname}" >> ~grafana/.aws/credentials | ||
if [ ! -z "${!region_varname}" ]; then | ||
echo "region = ${!region_varname}" >> ~grafana/.aws/credentials | ||
fi | ||
fi | ||
done | ||
> "$GF_PATHS_HOME/.aws/credentials" | ||
|
||
for profile in ${GF_AWS_PROFILES}; do | ||
access_key_varname="GF_AWS_${profile}_ACCESS_KEY_ID" | ||
secret_key_varname="GF_AWS_${profile}_SECRET_ACCESS_KEY" | ||
region_varname="GF_AWS_${profile}_REGION" | ||
|
||
if [ ! -z "${!access_key_varname}" -a ! -z "${!secret_key_varname}" ]; then | ||
echo "[${profile}]" >> "$GF_PATHS_HOME/.aws/credentials" | ||
echo "aws_access_key_id = ${!access_key_varname}" >> "$GF_PATHS_HOME/.aws/credentials" | ||
echo "aws_secret_access_key = ${!secret_key_varname}" >> "$GF_PATHS_HOME/.aws/credentials" | ||
if [ ! -z "${!region_varname}" ]; then | ||
echo "region = ${!region_varname}" >> "$GF_PATHS_HOME/.aws/credentials" | ||
fi | ||
fi | ||
done | ||
|
||
chown grafana:grafana -R ~grafana/.aws | ||
chmod 600 ~grafana/.aws/credentials | ||
chmod 600 "$GF_PATHS_HOME/.aws/credentials" | ||
fi | ||
|
||
if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then | ||
OLDIFS=$IFS | ||
IFS=',' | ||
for plugin in ${GF_INSTALL_PLUGINS}; do | ||
IFS=$OLDIFS | ||
gosu grafana grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin} | ||
grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin} | ||
done | ||
fi | ||
|
||
exec gosu grafana /usr/sbin/grafana-server \ | ||
--homepath=/usr/share/grafana \ | ||
--config="$GF_PATHS_CONFIG" \ | ||
cfg:default.log.mode="console" \ | ||
cfg:default.paths.data="$GF_PATHS_DATA" \ | ||
cfg:default.paths.logs="$GF_PATHS_LOGS" \ | ||
cfg:default.paths.plugins="$GF_PATHS_PLUGINS" \ | ||
cfg:default.paths.provisioning=$GF_PATHS_PROVISIONING \ | ||
"$@" | ||
exec grafana-server \ | ||
--homepath="$GF_PATHS_HOME" \ | ||
--config="$GF_PATHS_CONFIG" \ | ||
"$@" \ | ||
cfg:default.log.mode="console" \ | ||
cfg:default.paths.data="$GF_PATHS_DATA" \ | ||
cfg:default.paths.logs="$GF_PATHS_LOGS" \ | ||
cfg:default.paths.plugins="$GF_PATHS_PLUGINS" \ | ||
cfg:default.paths.provisioning="$GF_PATHS_PROVISIONING" |