Closed chriscroome closed 3 years ago
I have found a set of Ansible HTTP install tasks for Matomo so I've adopted this approach and it seems to work OK.
I guess something has changed again - I will look into it next week.
Hi,
I have looked into it now, and I can not reproduce this issue.
This is the Dockerfile we are using:
FROM php:7.4.13-fpm-alpine3.12
LABEL maintainer="Mikke Schirén <mikke.schiren@digitalistgroup.com>"
LABEL name="digi-base-matomo"
LABEL version="0.3"
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV MATOMO_VERSION 4.1.1
ENV MAXMIND_URL https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=LICENSEKEY&suffix=tar.gz
# Simplify installing extensions with this script:
# https://github.com/mlocati/docker-php-extension-installer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN set -ex; \
\
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
autoconf \
freetype-dev \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
openldap-dev \
pcre-dev \
; \
\
install-php-extensions xdebug; \
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-configure ldap; \
docker-php-ext-install -j "$(nproc)" \
gd \
ldap \
mysqli \
opcache \
pdo_mysql \
zip \
; \
\
# pecl will claim success even if one install fails, so we need to perform each install separately
pecl install APCu-5.1.19; \
pecl install redis-5.3.2; \
\
docker-php-ext-enable \
apcu \
redis \
; \
\
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --virtual .matomo-phpext-rundeps $runDeps; \
apk update && apk upgrade && apk add --no-cache autoconf bash geoip geoip-dev git libmaxminddb mysql-client rsync && \
apk add --no-cache --virtual .build-deps $PHPIZE_DEPS && \
git config --global advice.detachedHead false; \
curl -L https://github.com/maxmind/libmaxminddb/releases/download/1.3.2/libmaxminddb-1.3.2.tar.gz >> ./libmaxminddb-1.3.2.tar.gz \
&& tar -xf libmaxminddb-1.3.2.tar.gz \
&& ( \
cd libmaxminddb* \
&& ./configure \
&& make \
&& make install \
) \
&& rm -r libmaxminddb* \
# MaxMind GeoIP Reader
&& curl -L https://github.com/maxmind/MaxMind-DB-Reader-php/archive/v1.5.0.tar.gz >> ./MaxMind-DB-Reader-php-1.4.1.tar.gz \
&& tar -xf MaxMind-DB-Reader-php-1.4.1.tar.gz \
&& ( \
cd MaxMind-DB-Reader-php-*/ext \
&& cp /usr/local/include/maxminddb.h ./maxminddb.h \
&& cp /usr/local/include/maxminddb_config.h ./maxminddb_config.h \
&& phpize \
&& ./configure \
&& make \
&& make install \
) \
&& rm -r MaxMind-DB-Reader* \
&& docker-php-ext-enable maxminddb \
&& echo "geoip.custom_directory=/var/www/html/misc" >> /usr/local/etc/php/conf.d/docker-php-ext-geoip.ini && \
echo "display_errors=0" >> /usr/local/etc/php/conf.d/docker-php-general.ini && \
echo "log_errors=on" >> /usr/local/etc/php/conf.d/docker-php-general.ini && \
echo "memory_limit=2G" >> /usr/local/etc/php/conf.d/docker-php-general.ini && \
echo "error_log = /dev/stderr" >> /usr/local/etc/php/conf.d/docker-php-general.ini && \
echo "max_execution_time=300" >> /usr/local/etc/php/conf.d/docker-php-general.ini && \
echo "always_populate_raw_post_data=-1" >> /usr/local/etc/php/conf.d/docker-php-general.ini && \
echo "expose_php=Off" >> /usr/local/etc/php/conf.d/docker-php-general.ini && \
echo "opcache.enable_cli=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini && \
echo "opcache.memory_consumption=128" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini && \
echo "opcache.interned_strings_buffer=8" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini && \
# How many files do we have? Code base around 20000 with plugins, add to that some rendered twig files etc.
# We could check how many .php files we have with `ls -lR /var/www/html/ | grep ".php$" | wc -l`
echo "opcache.max_accelerated_files=30139" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini && \
# We are in a kubernetes world, code will never change on the pod. When we do a new release the old pod
# is removed, so use opcache heavily, and never revalidate.
echo "opcache.revalidate_freq=0" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini && \
echo "opcache.validate_timestamps=0" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini && \
echo "opcache.fast_shutdown=1" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
&& docker-php-source delete \
&& apk add --no-cache supervisor \
&& apk del --no-cache .build-deps; \
apk add --no-cache --virtual .fetch-deps \
git \
; \
\
cd /tmp; \
git clone https://github.com/matomo-org/matomo.git; \
cd matomo; \
git checkout ${MATOMO_VERSION}; \
git submodule init; \
git submodule update; \
rm -rf .git; \
rm -rf /var/www/html; \
cd /tmp; \
mv /tmp/matomo /var/www/html
COPY docker-entrypoint.sh /entrypoint.sh
WORKDIR /var/www/html
COPY plugins.sh plugins.sh
COPY assets.sh assets.sh
# temp patch hopefully
COPY patches/invalidate-segment.patch /var/www/html/invalidate-segment.patch
COPY patches/pause-archive.patch /var/www/html/pause-archive.patch
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
autoconf \
freetype-dev \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
openldap-dev \
pcre-dev \
patch \
; \
cd /var/www/html && patch -p1 < invalidate-segment.patch \
&& rm /var/www/html/invalidate-segment.patch \
&& cd /var/www/html && patch -p1 < pause-archive.patch \
&& rm /var/www/html/pause-archive.patch \
&& curl -sS https://getcomposer.org/installer | php; \
mv composer.phar /usr/local/bin/composer; \
./plugins.sh; \
./assets.sh; \
composer install -n --no-dev --no-scripts \
&& composer require symfony/process:^3.4 symfony/yaml:~2.6.0 \
&& curl "$MAXMIND_URL" -o /tmp/GeoLite2-City.tar.gz \
&& cd /tmp && tar xvf /tmp/GeoLite2-City.tar.gz \
&& mv /tmp/GeoLite2-City*/GeoLite2-City.mmdb /var/www/html/misc/GeoLite2-City.mmdb \
&& rm -rf /tmp/GeoLite* \
&& mkdir /usr/src/matomo \
&& rsync -crlOt --no-owner --no-group --no-perms /var/www/html/ /usr/src/matomo/ \
&& mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& chown www-data:www-data /etc/supervisord.conf \
&& touch /var/log/supervisord.log \
&& chown www-data:www-data /var/log/supervisord.log \
&& chown www-data:www-data -R /usr/src/matomo \
&& chown www-data:www-data -R /var/www/html \
&& chgrp www-data -R /var/www/html \
&& rm -rf /root/.composer/cache \
&& cd /var/www/html/ \
&& rm -f ./plugins.sh \
&& rm -f ./assets.sh \
&& apk del --no-cache .build-deps
ENTRYPOINT ["/entrypoint.sh"]
USER www-data
CMD ["php-fpm"]
plugins.sh:
#!/bin/bash
plugins=( CustomOptOut GroupPermissions InvalidateReports AdminNotification TagManager ExtraTools UserConsole QueuedTracking )
for i in "${plugins[@]}"
do
curl -f -sS https://plugins.matomo.org/api/2.0/plugins/$i/download/latest > /tmp/$i.zip
unzip /tmp/$i.zip -q -d /var/www/html/plugins -o
echo adding $i
done
# clean up
rm -rf /tmp/*
assets.sh is just downloading some custom webfonts and icons.
Here is a testrun:
Running with gitlab-runner 13.3.1 (738bbe5a)
on se-ops gp_vXpPA
Preparing the "docker" executor
00:03
Using Docker executor with image docker:git ...
Pulling docker image docker:git ...
Using docker image sha256:d6623ebd8af8380d0274da05d7db6d66e5f56fc6d462cd29d6a0fcb48aa8112b for docker:git ...
Preparing environment
00:01
Running on runner-gpvxppa-project-497-concurrent-0 via 90ff4dbf02c1...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/se-ops/docker/matomo-docker-base/.git/
Checking out 5090059c as 4.1.1-php7.4.13-fpm-alpine3.12...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:28
$ mkdir -p /root/.docker
$ echo "{\"auths\":{\"$REGISTRY\":{\"username\":\"$REGISTRY_USER\",\"password\":\"$REGISTRY_PASSWORD\"}}}" > /root/.docker/config.json
$ docker pull $IMAGE
4-1-1-php7-4-13-fpm-alpine3-12-5090059c: Pulling from matomo/base
Digest: sha256:c1bdb4d851adee98a9301014f99d26d3e59199e4d83fd70e6548c0800fb80166
Status: Image is up to date for privateregistry/matomo/base:4-1-1-php7-4-13-fpm-alpine3-12-5090059c
privateregistry/matomo/base:4-1-1-php7-4-13-fpm-alpine3-12-5090059c
$ docker network create analyse
825ffbcf0236d7e50b7404272c03727374b64053a7a2892bbf2658b3bfc1b1e2
$ docker run -p 3306:3306 --net=analyse --name db -d -e MYSQL_DATABASE=$MYSQL_DATABASE -e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD -e MYSQL_USER=$MYSQL_USER -e MYSQL_PASSWORD=$MYSQL_PASSWORD mysql:5.7 ; sleep 10
f7137181170fee5de35d895f732a0559f6fc64805e74d06cb0290d4e14a69514
$ docker run -p 9000:9000 -e MATOMO_DATABASE_HOST=db -e MATOMO_DATABASE_TABLES_PREFIX=_matomo -e MATOMO_DATABASE_USERNAME=$MYSQL_USER -e MATOMO_DATABASE_PASSWORD=$MYSQL_PASSWORD -e MATOMO_DATABASE_DBNAME=$MYSQL_DATABASE --net=analyse --name matomo -d $IMAGE ; sleep 10
9aab0e948cb3da91d0dc6604a482f744e9fba01d28653ebd865dc8b823940d53
$ docker cp dev/config/install.json matomo:/tmp/install.json
$ docker exec -i matomo ./console plugin:activate ExtraTools || true
The configuration file {/var/www/html/config/config.ini.php} has not been found or could not be read.
» Please check that /var/www/html/config/config.ini.php is readable by the user 'www-data'.
ERROR [2021-01-19 20:48:56] 9 There was an error while updating the javascript tracker: SQLSTATE[HY000] [2002] No such file or directory
ERROR [2021-01-19 20:48:56] 9 There was an error while updating the javascript tracker: SQLSTATE[HY000] [2002] No such file or directory
Activated plugin ExtraTools
Error: error or warning logs detected, exit 1
$ docker exec -i matomo ./console matomo:install --install-file=/tmp/install.json --do-not-drop-db --force
Installing Matomo
Starting install
Deleting cache
Initialising Database Connections
Create Matomo core tables
Updating Components
Creating Super user
Activated Diagnostics
Activated DBStats
Activated Login
Activated CoreAdminHome
Activated UsersManager
Activated SitesManager
Activated Installation
Activated Monolog
Activated Intl
Activated CorePluginsAdmin
Activated CoreHome
Activated WebsiteMeasurable
Activated CoreVisualizations
Activated Proxy
Activated API
Activated Transitions
Activated Actions
Activated Referrers
Activated UserLanguage
Activated DevicesDetection
Activated Goals
Activated SEO
Activated Events
Activated UserCountry
Activated GeoIp2
Activated VisitsSummary
Activated VisitFrequency
Activated VisitTime
Activated VisitorInterest
Activated CoreUpdater
Activated CoreConsole
Activated UserCountryMap
Activated Live
Activated ImageGraph
Activated Annotations
Activated Insights
Activated Morpheus
Activated Contents
Activated DevicePlugins
Activated UserId
Activated ExtraTools
Activated LanguagesManager
Activated SegmentEditor
Activated Dashboard
Activated ScheduledReports
Activated PrivacyManager
Activated CustomVariables
Activated IntranetMeasurable
Activated Widgetize
Activated MultiSites
Activated Ecommerce
Activated RssWidget
Activated Feedback
Activated TwoFactorAuth
Activated MobileMessaging
Activated Overlay
Activated TestRunner
Activated BulkTracking
Activated Resolution
Activated Heartbeat
Activated Marketplace
Activated ProfessionalServices
Activated LogViewer
Deactivated Feedback
Finalising...
We are done! Welcome to Matomo!
Now you can login with user admin and password xxxx
Running after_script
00:02
Running after script...
$ docker rm -vf matomo db
matomo
db
$ docker network rm analyse
analyse
Job succeeded
Though I discovered another issue related to creation of the first, I will look into it.
Sorry for not coming back earlier - but the install works fine for me, I was wrong with the creation of the first site, and can't reproduce the error.
Hi @mikkeschiren I did look at this issue the other day and I suspect it might have been caused because you install with a git version of Matomo and I was using a tgz version, there might be some missing PHP libraries or something in the tgz version? However this isn't a issue for me at the moment I have switched to automating the install using the web interface for now.
Ok, closing this then :-)
Should an install of the
4.x-dev
branch work?I'm finding that every step I was using fails, for example:
This is after downloading Matomo 4.0.5 and adding the composer.json from github.
Am I missing something here?