[bitnami/grafana] Ensure bitnami/grafana folder is created with usable permissions (#52255)

* Ensure bitnami/grafana folder is created with usable permissions

This follows the examples of other images.
Without this folder being created, mounting user init scripts leads
to an error on startup:
"mkdir: cannot create directory '/bitnami': Permission denied"

fixes #52238

Signed-off-by: Ben Foster <bpfoster@gmail.com>

* Adjust volume dir variable name and use grafana_env_var_value to reference it, per PR feedback

Signed-off-by: Ben Foster <bpfoster@gmail.com>

---------

Signed-off-by: Ben Foster <bpfoster@gmail.com>
This commit is contained in:
Ben Foster
2024-02-01 15:23:19 +01:00
committed by GitHub
parent 7a369fdde8
commit d9b3adfc9f
2 changed files with 2 additions and 1 deletions
@@ -77,6 +77,7 @@ GF_INSTALL_PLUGINS="${GF_INSTALL_PLUGINS:-"${GRAFANA_PLUGINS:-}"}"
export GF_INSTALL_PLUGINS="${GF_INSTALL_PLUGINS:-}"
export GF_INSTALL_PLUGINS_SKIP_TLS="${GF_INSTALL_PLUGINS_SKIP_TLS:-yes}"
export GF_FEATURE_TOGGLES="${GF_FEATURE_TOGGLES:-}"
export GF_VOLUME_DIR="${BITNAMI_VOLUME_DIR}/grafana"
export GRAFANA_MIGRATION_LOCK="${GRAFANA_MIGRATION_LOCK:-false}"
export GRAFANA_SLEEP_TIME="${GRAFANA_SLEEP_TIME:-10}"
export GRAFANA_RETRY_ATTEMPTS="${GRAFANA_RETRY_ATTEMPTS:-12}"
@@ -25,7 +25,7 @@ info "Creating system user"
ensure_user_exists "$GRAFANA_DAEMON_USER" --group "$GRAFANA_DAEMON_GROUP" --system
info "Configuring file permissions"
for dir in "$(grafana_env_var_value PATHS_DATA)" "$(grafana_env_var_value PATHS_LOGS)" "$(grafana_env_var_value PATHS_PLUGINS)" "$(grafana_env_var_value PATHS_PROVISIONING)"; do
for dir in "$(grafana_env_var_value PATHS_DATA)" "$(grafana_env_var_value PATHS_LOGS)" "$(grafana_env_var_value PATHS_PLUGINS)" "$(grafana_env_var_value PATHS_PROVISIONING)" "$(grafana_env_var_value VOLUME_DIR)"; do
ensure_dir_exists "$dir"
# Use grafana:root ownership for compatibility when running as a non-root user
configure_permissions_ownership "$dir" -d "775" -f "664" -u "$GRAFANA_DAEMON_USER" -g "root"