docker icon indicating copy to clipboard operation
docker copied to clipboard

[PROPOSAL] Build config file using environment variables

Open brunowego opened this issue 6 years ago • 2 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?

brunowego avatar Oct 18 '19 11:10 brunowego

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

jnmcfly avatar Nov 12 '19 13:11 jnmcfly

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.

diogenes1oliveira avatar Dec 16 '19 19:12 diogenes1oliveira

duplicate of https://github.com/matomo-org/matomo/issues/10257

J0WI avatar Nov 26 '22 15:11 J0WI