Add matomo container

This commit is contained in:
Alejandro Celaya 2023-06-04 12:40:10 +02:00
parent 36e2a9387d
commit b4386a3508
3 changed files with 58 additions and 30 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ vendor/
data/database.sqlite data/database.sqlite
data/shlink-tests.db data/shlink-tests.db
data/GeoLite2-City.* data/GeoLite2-City.*
data/infra/matomo
docs/swagger-ui* docs/swagger-ui*
docs/mercure.html docs/mercure.html
docker-compose.override.yml docker-compose.override.yml

View File

@ -22,33 +22,39 @@ use const PHP_SAPI;
$isTestEnv = env('APP_ENV') === 'test'; $isTestEnv = env('APP_ENV') === 'test';
$enableSwoole = PHP_SAPI === 'cli' && openswooleIsInstalled() && ! runningInRoadRunner(); $enableSwoole = PHP_SAPI === 'cli' && openswooleIsInstalled() && ! runningInRoadRunner();
return (new ConfigAggregator\ConfigAggregator([ return (new ConfigAggregator\ConfigAggregator(
! $isTestEnv providers: [
? new EnvVarLoaderProvider('config/params/generated_config.php', enumValues(Core\Config\EnvVars::class)) ! $isTestEnv
: new ConfigAggregator\ArrayProvider([]), ? new EnvVarLoaderProvider('config/params/generated_config.php', enumValues(Core\Config\EnvVars::class))
Mezzio\ConfigProvider::class, : new ConfigAggregator\ArrayProvider([]),
Mezzio\Router\ConfigProvider::class, Mezzio\ConfigProvider::class,
Mezzio\Router\FastRouteRouter\ConfigProvider::class, Mezzio\Router\ConfigProvider::class,
$enableSwoole && class_exists(Swoole\ConfigProvider::class) Mezzio\Router\FastRouteRouter\ConfigProvider::class,
? Swoole\ConfigProvider::class $enableSwoole && class_exists(Swoole\ConfigProvider::class)
: new ConfigAggregator\ArrayProvider([]), ? Swoole\ConfigProvider::class
ProblemDetails\ConfigProvider::class, : new ConfigAggregator\ArrayProvider([]),
Diactoros\ConfigProvider::class, ProblemDetails\ConfigProvider::class,
Common\ConfigProvider::class, Diactoros\ConfigProvider::class,
Config\ConfigProvider::class, Common\ConfigProvider::class,
Importer\ConfigProvider::class, Config\ConfigProvider::class,
IpGeolocation\ConfigProvider::class, Importer\ConfigProvider::class,
EventDispatcher\ConfigProvider::class, IpGeolocation\ConfigProvider::class,
Core\ConfigProvider::class, EventDispatcher\ConfigProvider::class,
CLI\ConfigProvider::class, Core\ConfigProvider::class,
Rest\ConfigProvider::class, CLI\ConfigProvider::class,
new ConfigAggregator\PhpFileProvider('config/autoload/{,*.}global.php'), Rest\ConfigProvider::class,
// Local config should not be loaded during tests, whereas test config should be loaded ONLY during tests new ConfigAggregator\PhpFileProvider('config/autoload/{,*.}global.php'),
new ConfigAggregator\PhpFileProvider($isTestEnv ? 'config/test/*.global.php' : 'config/autoload/{,*.}local.php'), // Local config should not be loaded during tests, whereas test config should be loaded ONLY during tests
// Routes have to be loaded last new ConfigAggregator\PhpFileProvider(
new ConfigAggregator\PhpFileProvider('config/autoload/routes.config.php'), $isTestEnv ? 'config/test/*.global.php' : 'config/autoload/{,*.}local.php',
], 'data/cache/app_config.php', [ ),
Core\Config\PostProcessor\BasePathPrefixer::class, // Routes have to be loaded last
Core\Config\PostProcessor\MultiSegmentSlugProcessor::class, new ConfigAggregator\PhpFileProvider('config/autoload/routes.config.php'),
Core\Config\PostProcessor\ShortUrlMethodsProcessor::class, ],
]))->getMergedConfig(); cachedConfigFile: 'data/cache/app_config.php',
postProcessors: [
Core\Config\PostProcessor\BasePathPrefixer::class,
Core\Config\PostProcessor\MultiSegmentSlugProcessor::class,
Core\Config\PostProcessor\ShortUrlMethodsProcessor::class,
],
))->getMergedConfig();

View File

@ -33,6 +33,7 @@ services:
- shlink_mercure - shlink_mercure
- shlink_mercure_proxy - shlink_mercure_proxy
- shlink_rabbitmq - shlink_rabbitmq
- shlink_matomo
environment: environment:
LC_ALL: C LC_ALL: C
extra_hosts: extra_hosts:
@ -70,6 +71,7 @@ services:
- shlink_mercure - shlink_mercure
- shlink_mercure_proxy - shlink_mercure_proxy
- shlink_rabbitmq - shlink_rabbitmq
- shlink_matomo
environment: environment:
LC_ALL: C LC_ALL: C
extra_hosts: extra_hosts:
@ -95,6 +97,7 @@ services:
- shlink_mercure - shlink_mercure
- shlink_mercure_proxy - shlink_mercure_proxy
- shlink_rabbitmq - shlink_rabbitmq
- shlink_matomo
environment: environment:
LC_ALL: C LC_ALL: C
extra_hosts: extra_hosts:
@ -201,3 +204,21 @@ services:
- "8005:8080" - "8005:8080"
volumes: volumes:
- ./docs/swagger:/app - ./docs/swagger:/app
shlink_matomo:
container_name: shlink_matomo
image: matomo:4.14-apache
ports:
- "8003:80"
volumes:
# Matomo does not persist port in trusted hosts. This is needed to edit config afterwards
# https://github.com/matomo-org/matomo/issues/9549
- ./data/infra/matomo:/var/www/html
links:
- shlink_db_mysql
environment:
MATOMO_DATABASE_HOST: "shlink_db_mysql"
MATOMO_DATABASE_ADAPTER: "mysql"
MATOMO_DATABASE_DBNAME: "matomo"
MATOMO_DATABASE_USERNAME: "root"
MATOMO_DATABASE_PASSWORD: "root"