]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6693 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 29 Jan 2024 17:27:52 +0000 (18:27 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 29 Jan 2024 17:27:52 +0000 (18:27 +0100)
app/Http/Controllers/Admin/Operations/Tools/DockerWebContainer.php
resources/tools/dockerwebcontainer/template/images/php-fpm/Dockerfile

index 8a80da4e1a814cd2658a44dd4bded6a6604df612..28b824fbe6fae8359d536dafce18ea1b69ed1e40 100644 (file)
@@ -30,16 +30,17 @@ trait DockerWebContainer
         $form->addField('domain', Text::class, __('Nom du domaine ou sous-domaine'), ['placeholder' => 'containername.dev.cubedesigners.com']);
         $form->addField('env', SelectFromArrayMultiple::class, __('Environnements'), ['default' => json_encode(['production', 'dev']), 'options' => ['production' => 'production', 'dev' => 'dev', 'staging' => 'staging', 'preprod' => 'preprod']]);
         $form->addField('public', Checkbox::class, __('Racine dans le dossier "public"'), ['default' => true]);
+        $form->addField('laravel', Checkbox::class, __('Installer Laravel'), ['default' => true]);
         $form->addField('phpversion', SelectFromArray::class, __('Version de PHP'), ["options" =>
             ['none' => '-',
                 '5.6' => '5.6',
                 '7.4' => '7.4',
-                '8.1' => '8.1',
                 '8.2' => '8.2',
-            ], 'value' => '8.2']);
+                '8.3' => '8.3',
+            ], 'value' => '8.3']);
         $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]);
+        $form->addField('matomo', Checkbox::class, __('Serveur Matomo'), ['default' => false]);
         $form->addField('elasticsearch', Checkbox::class, __('Serveur ElasticSearch'), ['default' => false]);
 
 
@@ -57,8 +58,10 @@ trait DockerWebContainer
         $notification = __('Le container web :name a été crée avec les informations suivantes', ['name' => $name]) . " : \n\n";
 
         foreach ($envs as $env) {
+            $domain = $request->get('domain', '');
+
             $notification .= '---- Environnement : ' . $env . " ----\n\n";
-            $subDomain = $env === 'production' ? 'www.' : $env . '.';
+            $subDomain = $env === 'production' ? (substr_count($domain, '.') >= 2 ? '' : 'www.') : $env . '.';
             $dockerSuffix = $env === 'production' ? '' : '-' . $env;
 
             if (count($envs) === 1) {
@@ -68,7 +71,7 @@ trait DockerWebContainer
             $variables = ['$name' => $name . $dockerSuffix,
                 '$matomodbpassword' => Str::random(16),
                 '$sshport' => rand(10000, 60000),
-                '$domain' => $request->get('domain', ''),
+                '$domain' => $domain,
                 '$dbpassword' => Str::random(16),
                 '$phpfpmimage' => 'php-fpm',
                 '$locale' => 'fr_FR',
@@ -88,7 +91,7 @@ trait DockerWebContainer
             `cp -r $source/* $dir/`;
 
             $compose = ['base'];
-            $variables['$phpversion'] = $request->get('phpversion', '8.1');
+            $variables['$phpversion'] = $request->get('phpversion', '8.3');
             if ($variables['$phpversion'] !== 'none') {
                 $compose[] = 'php';
                 if (version_compare($variables['$phpversion'], '5.6', '<=')) {
@@ -112,6 +115,19 @@ trait DockerWebContainer
                 $fixRights[] = 'chmod -R 777 ./esdata';
             }
 
+            if ($request->get('laravel', true)) {
+                `rm -rf $dir/www;composer create-project laravel/laravel $dir/www`;
+                $composerFile = $dir . '/www/composer.json';
+                $composer = json_decode(file_get_contents($composerFile));
+                $composer->name = $name;
+                $composer->license = 'Proprietary';
+                $composer->keywords = [$name];
+                $composer->descriptions = $name . ' project';
+                $composer->require->{"cubist/cms-back"} = 'dev-backpack5';
+                file_put_contents($composerFile, json_encode($composer));
+                `rm -rf $dir/www/vendor`;
+            }
+
             $variables['$fixrights'] = implode("\n", $fixRights);
 
             $compose[] = 'network';
index a02c3060ce80d01f41e4660791f983194416f52e..5166bca3ff359ae3e1871566a0987da879b4a051 100644 (file)
@@ -48,7 +48,7 @@ RUN apt -y --no-install-recommends install \
         php$phpversion-tidy \
         php$phpversion-xsl \
         php$phpversion-curl \
-        php$phpversion-mcrypt \
+        php$phpversion-bcmath \
         php$phpversion-fpm \
         less nano wget nodejs