]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6058 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 19 Jun 2023 14:53:25 +0000 (16:53 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 19 Jun 2023 14:53:25 +0000 (16:53 +0200)
app/Http/Controllers/Admin/Operations/Tools/DockerWebContainer.php
resources/tools/dockerwebcontainer/matomo [new file with mode: 0644]

index c55955c4b599b97e4b74c7112fc53a2c2df4ae75..0ab21f978b0dcd31d5fafd86b0225e1b3d797f84 100644 (file)
@@ -40,6 +40,7 @@ trait DockerWebContainer
             ], 'value' => '8.2']);
         $form->addField('mysql', Checkbox::class, __('Serveur Mariadb') . ' (MySQL)', ['default' => true]);
         $form->addField('redis', Checkbox::class, __('Serveur Redis'), ['default' => true]);
+        $form->addField('matomo', Checkbox::class, __('Serveur Matomo'), ['default' => true]);
 
         return view('tools.form', ['form' => $form]);
     }
@@ -50,6 +51,8 @@ trait DockerWebContainer
         $name = Str::slug($request->get('containername', 'containername'));
         $variables = ['$name' => $name,
             '$portadminer' => rand(10000, 60000),
+            '$portmatomo' => rand(10000, 60000),
+            '$matomodbpassword' => Str::random(16),
             '$port' => rand(10000, 60000),
             '$sshport' => rand(10000, 60000),
             '$domain' => $request->get('domain', ''),
@@ -80,6 +83,9 @@ trait DockerWebContainer
         if ($request->get('mysql', true)) {
             $compose[] = 'mysql';
         }
+        if ($request->get('matomo', true)) {
+            $compose[] = 'matomo';
+        }
         $compose[] = 'network';
         $composeFileContent = '';
         foreach ($compose as $item) {
@@ -96,17 +102,22 @@ trait DockerWebContainer
         $res = response()->download($tmpfile, $name . '.zip')->deleteFileAfterSend(true);
         $notification = __('Le container web :name a été crée avec les informations suivantes', ['name' => $variables['$name']]) . "\n";
         $infos = [
-            'URL' => 'https://' . $variables['$domain'] . '/',
-            __('Hôte de base de données') => $variables['$name'] . '-mariadb',
-            __('Nom de base de données') => $variables['$name'],
-            __('Utilisateur de la base de données') => 'root',
-            __('Mot de passe de la base de données') => $variables['$dbpassword'],
-            'Adminer' => 'https://adminer.' . $variables['$domain'] . '/',
-            __('Serveur SSH/SFTP') => $variables['$domain'],
-            __('Port') => $variables['$sshport'],
-            __('Utilisateur') => $variables['$name'],
-            __('Mot de passe') => $variables['$sshpassword'],
-        ];
+            'URL' => 'https://' . $variables['$domain'] . '/'];
+
+        if ($request->get('mysql', true)) {
+            $infos = array_merge($infos,
+                [
+                    __('Hôte de base de données') => $variables['$name'] . '-mariadb',
+                    __('Nom de base de données') => $variables['$name'],
+                    __('Utilisateur de la base de données') => 'root',
+                    __('Mot de passe de la base de données') => $variables['$dbpassword'],
+                    'Adminer' => 'https://adminer.' . $variables['$domain'] . '/',
+                    __('Serveur SSH/SFTP') => $variables['$domain'],
+                    __('Port') => $variables['$sshport'],
+                    __('Utilisateur') => $variables['$name'],
+                    __('Mot de passe') => $variables['$sshpassword'],
+                ]);
+        }
         foreach ($infos as $k => $v) {
             $notification .= '* ' . $k . ' : ' . $v . "\n";
         }
diff --git a/resources/tools/dockerwebcontainer/matomo b/resources/tools/dockerwebcontainer/matomo
new file mode 100644 (file)
index 0000000..a86901d
--- /dev/null
@@ -0,0 +1,58 @@
+    matomo-db:
+      image: mariadb
+      container_name: $name-matomo-mariadb
+      command: --max-allowed-packet=64MB
+      restart: unless-stopped
+      volumes:
+        - ./matomo/database/data:/var/lib/mysql
+      environment:
+        MARIADB_ROOT_PASSWORD: "$matomodbpassword"
+        MARIADB_DATABASE: $name-matomo
+        MARIADB_AUTO_UPGRADE: 1
+      networks:
+        - $name
+
+    matomo:
+      image: 'matomo:latest'
+      container_name: $name-matomo
+      environment:
+        MATOMO_DATABASE_ADAPTER: mysql
+        MATOMO_DATABASE_USERNAME: root
+        MATOMO_DATABASE_PASSWORD: "$matomodbpassword"
+        MATOMO_DATABASE_DBNAME: $name-matomo
+        VIRTUAL_HOST: matomo.$domain
+        LETSENCRYPT_HOST: matomo.$domain
+      volumes:
+        - ./matomo/config:/var/www/html/config
+        - ./matomo/logs:/var/www/html/logs
+        - ./matomo/matomo:/var/www/html
+        - ./matomo/bin:/var/www/html/bin
+      restart: unless-stopped
+      ports:
+        - $portmatomo:80
+      networks:
+        - $name
+
+    matomo-mysqlbackup:
+      image: selim13/automysqlbackup
+      container_name: $name-matomo-automysqlbackup
+      volumes:
+        - "./matomo/database/backup:/backup"
+      environment:
+        USERNAME: root
+        PASSWORD: "$matomodbpassword"
+        DBHOST: $name-matomo-mariadb
+        DBEXCLUDE: "performance_schema information_schema"
+        CRON_SCHEDULE: "0 0 * * *"
+        EXTRA_OPTS: "--single-transaction"
+      networks:
+        - $name
+
+    matomo-redis:
+      image: redis
+      container_name: $name-matomo-redis
+
+      volumes:
+        - ./matomo/redis:/data
+      networks:
+        - $name