matomo-org/docker

[PROPOSAL] Build config file using environment variables

brunowego opened this issue · 3 comments

This is just an idea that crossed my mind. Use variables to build config file, like:

MATOMO_CONF_database__host=mysql
MATOMO_CONF_database__username=matomo
MATOMO_CONF_database__password=matomo
MATOMO_CONF_database__dbname=matomo
MATOMO_CONF_database__tables_prefix=matomo_
MATOMO_CONF_database__adapter=MYSQLI

MATOMO_CONF_general__enable_browser_archiving_triggering=0
MATOMO_CONF_general__enable_sql_optimize_queries=0
MATOMO_CONF_general__enable_trusted_host_check=0
MATOMO_CONF_general__enable_internet_features=0
MATOMO_CONF_general__enable_auto_update=0
MATOMO_CONF_general__enable_update_communication=0
MATOMO_CONF_general__enable_marketplace=0
#! /bin/bash

function addConfig() {
  local section=$1
  local key=$2
  local value=$3

  php console config:set \
    --section="$section" \
    --key="$key" \
    --value="$value"
}

for c in $(printenv | perl -sne 'print "$1 " if m/^MATOMO_CONF_(.+?)=.*/'); do
  section_key=$(echo "${c}" | perl -pe 's/__/ /g')
  var="MATOMO_CONF_${c}"
  value=${!var}

  echo " - Setting $section_key=$value"
  addConfig "$section_key" "$value"
done

Does it make any sense to you?

We're at this point right now. Makes sense to me! lets have a env for trusted hosts!

We're at this point right now. Makes sense to me! lets have a env for trusted hosts!

Hello, @jnmcfly, at what point are you at this? I've done something similar in our deployment and perhaps I could open a pull request for it.