]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6555 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Dec 2023 19:09:53 +0000 (20:09 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 5 Dec 2023 19:09:53 +0000 (20:09 +0100)
.gitignore
app/Jobs/HostingUpdate.php [new file with mode: 0644]
resources/hosting/docker-compose.yml [deleted file]
resources/hosting/nginxproxy/config/custom_proxy_settings.conf [new file with mode: 0644]
resources/hosting/nginxproxy/config/timeout.conf [new file with mode: 0644]
resources/hosting/nginxproxy/docker-compose.yml
resources/hosting/nginxproxy/update
resources/hosting/server/docker-compose.yml [new file with mode: 0644]
resources/hosting/server/update [new file with mode: 0644]
resources/hosting/updateall

index 71ef69500fe2fa890079db53468863e5a221c2db..b1cc82198b9d3348d0e87192e209e35a1321290b 100644 (file)
@@ -25,3 +25,4 @@ yarn-error.log
 /resources/elearningmedia/css/
 /resources/linkeditor/dist/
 /resources/compiler/
+/protected/*
diff --git a/app/Jobs/HostingUpdate.php b/app/Jobs/HostingUpdate.php
new file mode 100644 (file)
index 0000000..a21fee2
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Models\FluidbookExternalInstallServer;
+use Cubist\Util\CommandLine\Rsync;
+use Cubist\Util\Files\Files;
+use Cubist\Util\Text;
+
+class HostingUpdate extends Base
+{
+
+    protected static $_data = [
+        //'hosting' => ['host' => 'clockwork.cubedesigners.com', 'basepath' => '/data/fluidbook/hosting', 'ip' => '178.33.250.33'],
+        'hosting2' => ['host' => 'clockwork.cubedesigners.com', 'basepath' => '/data/fluidbook/hosting2', 'ip' => '213.186.47.100'],
+        //'ushosting' => ['host' => 'kingkong.cubedesigners.com', 'basepath' => '/home/fluidbook/data/hosting', 'ip' => '134.148.91.250'],
+    ];
+
+    public function handle()
+    {
+        foreach (static::$_data as $name => $s) {
+            $this->updateHosting($name, $s);
+        }
+    }
+
+    protected function updateHosting($name, $data)
+    {
+        $d = Files::mkdir(protected_path('hosting/' . $name));
+        $r = Files::mkdir(resource_path('hosting'));
+        $servers = FluidbookExternalInstallServer::withoutGlobalScopes()->where('protocol', $name)->get();
+
+        $updateAll = [];
+
+        copy($r . 'updateall', $d . 'update');
+
+        foreach ($servers as $server) {
+            $s = $d . 'server-' . $server->id;
+            Files::copy($r . 'server', $s);
+            Files::recursiveReplaceStringInDir($s, [
+                '$sid' => $server->id,
+                '$image' => $server->php ? 'php:apache' : 'httpd',
+                '$dockerpath' => $server->php ? '/var/www/html' : '/usr/local/apache2/htdocs',
+                '$domains' => implode(',', Text::explodeNewLines($server->subdomains)),
+                '$hosting' => $name,
+                '$path' => $data['basepath'],
+            ]);
+            $updateAll[] = '/docker/fluidbook-' . $name . '/server-' . $server->id . '/update';
+        }
+
+        Files::recursiveReplaceStringInDir($d, [
+            '$hosting' => $name,
+            '$updateall' => implode("\n", $updateAll),
+            '$ip' => $data['ip']
+        ]);
+
+        chmod($d . 'update', 0755);
+        $rsync = new Rsync($d, 'root@' . $data['host'] . ':/docker/fluidbook-' . $name);
+        $rsync->setMirror(true);
+        $rsync->execute();
+
+
+    }
+}
diff --git a/resources/hosting/docker-compose.yml b/resources/hosting/docker-compose.yml
deleted file mode 100644 (file)
index 124a2bd..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-version: '3.1'
-services:
-    webserver:
-        container_name: fluidbook-$hosting-server-$sid
-        image: $image
-        volumes:
-            - '$path:/usr/local/apache2/htdocs'
-        environment:
-            VIRTUAL_HOST: $domains
-            LETSENCRYPT_HOST: $domains
-        networks:
-            - fluidbook-$hosting
-        restart: unless-stopped
-
-networks:
-  fluidbook-$hosting:
-    external:
-      name: fluidbook-$hosting
diff --git a/resources/hosting/nginxproxy/config/custom_proxy_settings.conf b/resources/hosting/nginxproxy/config/custom_proxy_settings.conf
new file mode 100644 (file)
index 0000000..227c534
--- /dev/null
@@ -0,0 +1,2 @@
+client_max_body_size 2m;
+
diff --git a/resources/hosting/nginxproxy/config/timeout.conf b/resources/hosting/nginxproxy/config/timeout.conf
new file mode 100644 (file)
index 0000000..579026a
--- /dev/null
@@ -0,0 +1,4 @@
+proxy_connect_timeout 30;
+proxy_send_timeout 30;
+proxy_read_timeout 30;
+send_timeout 30;
index 4b631fe38f074acb9719314e7b5382fe1d0ddd16..ada051e7574399dc395a810ac5e0076c1166ae50 100644 (file)
@@ -1,10 +1,11 @@
 version: '2'
 services:
-  nginx-proxy:
+  fluidbook-$hosting-nginx-proxy:
     image: nginxproxy/nginx-proxy
     container_name: fluidbook-$hosting-proxy
     networks:
       - fluidbook-$hosting
+    ports:
       - "$ip:80:80"
       - "$ip:443:443"
     volumes:
@@ -13,23 +14,9 @@ services:
       - ./config/custom_proxy_settings.conf:/etc/nginx/conf.d/custom_proxy_settings.conf:ro
       - ./vhosts:/etc/nginx/vhost.d
       - ./html:/usr/share/nginx/html
-      - ./certs:/etc/nginx/certs
+      - /docker/nginxproxy/certs:/etc/nginx/certs
     restart: unless-stopped
 
-  acme-companion:
-    image: nginxproxy/acme-companion
-    container_name: nginx-proxy-acme
-    networks:
-      - fluidbook-$hosting
-    environment:
-      - DEFAULT_EMAIL=vincent@cubedesigners.com
-    volumes_from:
-      - nginx-proxy
-    volumes:
-      - ./certs:/etc/nginx/certs:rw
-      - ./acme:/etc/acme.sh
-      - /var/run/docker.sock:/var/run/docker.sock:ro
-
 networks:
   fluidbook-$hosting:
     external:
index 29cddbda543b606b1725bca7241c1ff3a7798cac..b1082dd577d04c14965f628887d3ec31e69e8183 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/sh
-cd /docker/fluidbook-hosting/nginxproxy/
+cd /docker/fluidbook-$hosting/nginxproxy/
 docker-compose pull
 docker-compose down
 docker-compose up -d
diff --git a/resources/hosting/server/docker-compose.yml b/resources/hosting/server/docker-compose.yml
new file mode 100644 (file)
index 0000000..9e3745f
--- /dev/null
@@ -0,0 +1,18 @@
+version: '3.1'
+services:
+    webserver:
+        container_name: fluidbook-$hosting-server-$sid
+        image: $image
+        volumes:
+            - '$path:$dockerpath'
+        environment:
+            VIRTUAL_HOST: $domains
+            LETSENCRYPT_HOST: $domains
+        networks:
+            - fluidbook-$hosting
+        restart: unless-stopped
+
+networks:
+  fluidbook-$hosting:
+    external:
+      name: fluidbook-$hosting
diff --git a/resources/hosting/server/update b/resources/hosting/server/update
new file mode 100644 (file)
index 0000000..5e7dc4f
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+cd /docker/fluidbook-$hosting/server-$sid/
+docker-compose pull
+docker-compose down
+docker-compose up -d
index 74733e326f468b8d427610ce37d4666499257d23..c6be1abe66ff27a8177995aa53fa771575214f70 100644 (file)
@@ -1,4 +1,4 @@
 #!/bin/sh
 docker network create fluidbook-$hosting
-/docker/fluidbook-$hosting/nxginxproxy/update
-
+chmod 755 /docker/fluidbook-$hosting/*/update
+$updateall