Is it possible to install plugins prior to deployment to a server? Our server does not have Internet access, and all code must be scanned prior to uploading. I am interested in installing Custom Dimensions from it’s GitHub repo source code if possible.
You can download all plugins as ZIP files from the Marketplace (https://plugins.matomo.org/). Installing is then just a matter of extracting them into the plugins directory and then activating them from the console (
If you are using premium plugins the same can be done from Download Purchased Plugins - Matomo Plugins Marketplace and if you want to automate this step there is a script for inspiration here: matomo-enterprise/download-matomo-enterprise.sh at master · innocraft/matomo-enterprise · GitHub
I am experiencing some problems with this approach in my attempt to setup a docker image with matomo. The plugin needs to be installed as part of the build process.
Initial setup, in use today:
a matomo 3.11.0 installation. No plugins installed.
I’ve copied this database to another server to test.
New installation is based on 3.12.0. After starting the docker image matomo boots up and everything looks OK. A db-upgrade is performed through the UI.
Dockerfile contains, amongst other things:
RUN curl --cacert /usr/lib/ssl/cert.pem -fsSL -o customDimensions.zip \ "https://plugins.matomo.org/api/2.0/plugins/CustomDimensions/download/3.1.9"; RUN unzip customDimensions.zip -d /usr/src/piwik/plugins
Now, for the hard part: activating the plugin.
[...] | UserCountry | Core | Activated | | Tour | Core | Activated | | CustomDimensions | Optional | Not activated |
so we see that the plugin is recognized by Matomo.
root@7fe553820a3b:/usr/src/piwik# ./console plugin:activate CustomDimensions Activated plugin CustomDimensions
This updates the UI with a message saying the DB needs to be updated.
# These SQL queries will be executed: ALTER TABLE `matomo_custom_dimensions` ADD COLUMN `case_sensitive` TINYINT UNSIGNED NOT NULL DEFAULT 1 AFTER `extractions`; ALTER TABLE `matomo_custom_dimensions` DROP INDEX `idcustomdimension_idsite`; ALTER TABLE `matomo_custom_dimensions` ADD PRIMARY KEY(`idcustomdimension`, `idsite`);
This fails with the error
/usr/src/piwik/plugins/CustomDimensions/Updates/0.1.2.php: Error trying to execute the migration 'ALTER TABLE `matomo_custom_dimensions` ADD COLUMN `case_sensitive` TINYINT UNSIGNED NOT NULL DEFAULT 1 AFTER `extractions`;'. The error was: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'matomo.matomo_custom_dimensions' doesn't exist We automatically deactivated the following plugins: CustomDimensions
The cause looks straight forward enough, trying to alter non-present tables. However it is not clear to me when these tables should have been created in the first place?
(Edit to notify @Lukas )