Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

During installation allow to prefill DB form from environment variables #13676

Merged
merged 1 commit into from Nov 27, 2018

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Nov 7, 2018

refs #10914

@mattab as discussed pre-filling DB values from environment optionally. Supported are:

  • MATOMO_DATABASE_HOST
  • MATOMO_DATABASE_ADAPTER
  • MATOMO_DATABASE_TABLES_PREFIX
  • MATOMO_DATABASE_USERNAME
  • MATOMO_DATABASE_PASSWORD
  • MATOMO_DATABASE_DBNAME

and as fallback if that is not defined (we could also remove that fallback)

  • DATABASE_HOST
  • DATABASE_ADAPTER
  • DATABASE_TABLES_PREFIX
  • DATABASE_USERNAME
  • DATABASE_PASSWORD
  • DATABASE_DBNAME

The structure being taken from the global ini as in MATOMO_$CATEGORY_$SETTINGNAME.

I'm not going to implement that it overrides the config and that Matomo could be basically even used without config etc. Some settings will need to be writable I suppose and won't be possible to be set through environment variables. I wouldn't want it in core actually, and to overwrite / configure any environment setting I suggest this will be implemented in a separate plugin which can be put on the marketplace. For performance etc I wouldn't want to check environment variables for heaps of settings etc.

@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Nov 7, 2018
@tsteur tsteur added this to the 3.8.0 milestone Nov 7, 2018
@tsteur
Copy link
Member Author

tsteur commented Nov 7, 2018

As mentioned in the issue developed https://github.com/matomo-org/plugin-EnvironmentVariables but haven't tested it. If someone can confirm this works, we can publish it on the marketplace.

@baywet
Copy link

baywet commented Nov 14, 2018

I can test it, but not immediately, what do I need to do to test it? install matomo from this specific branch? Could you provide me a documentation on how to get the equivalent of the matomo.zip (release) from this branch please?

@tsteur
Copy link
Member Author

tsteur commented Nov 14, 2018

Easiest be to download the regular matomo.zip, install, and then replace the content of the file plugins/Installation/FormDatabaseSetup.php with this content: https://raw.githubusercontent.com/matomo-org/matomo/04381b4bec7a9afa7f923bd3dc1769e4e4768aa0/plugins/Installation/FormDatabaseSetup.php

@baywet
Copy link

baywet commented Nov 14, 2018

thanks! I'll try that as soon as I have a minute and let you know how it works

@diosmosis diosmosis merged commit aa977ef into 3.x-dev Nov 27, 2018
@diosmosis diosmosis deleted the 10914 branch November 27, 2018 04:59
@baywet
Copy link

baywet commented Dec 9, 2018

Sorry for the long delay on this one @tsteur
So this works, but in my understanding the only thing it does is reading the environment variables at setup time to pre-fill the form and then stores it into the config file.
It'd be better if matomo could read the configuration values from environment variables at runtime all the time. This is standard practice for all templated services approach (like arm templates, docker composed services….)

@tsteur
Copy link
Member Author

tsteur commented Dec 9, 2018

see #13676 (comment) @baywet

@baywet
Copy link

baywet commented Dec 9, 2018

Thanks for the fast reply! And sorry about that, I missed that comment today…
I works like a charm. Now as you might know I'm working on the Azure offering. Part of how this works is why a "deployment" repository which is used for the file copy of what needs to be hosted.
Right now I'm maintaining that repo manually but I'll have to automate that part now.
Is the EnvironmentVairables plugin going to be part of the default plugins (the matomo-latest.zip) ? and enabled by default (global.ini.php) ? or do I need to script that part as well?

@tsteur
Copy link
Member Author

tsteur commented Dec 9, 2018

Yes I know :) It will be a plugin on the Matomo Marketplace as we don't want to enable it by default. So you would basically download it from eg https://plugins.matomo.org/api/2.0/plugins/EnvironmentVariables/download/latest and simply have it already listed in your config/config.ini.php in Plugins[] = "EnvironmentVariables". You could also run a command to activate it eg ./console plugin:activate EnvironmentVariables but that might not work in your use case as it needs to be enabled from the beginning I suppose.

@baywet
Copy link

baywet commented Dec 9, 2018

thanks! I'll add that to the script that creates my "image" from the matomo releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants