From: Vincent Vanwaelscappel Date: Tue, 5 Dec 2023 19:09:53 +0000 (+0100) Subject: wip #6555 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=4666a8c32e5f18f710b84e7b951467af3ef12b58;p=fluidbook-toolbox.git wip #6555 @1.5 --- diff --git a/.gitignore b/.gitignore index 71ef69500..b1cc82198 100644 --- a/.gitignore +++ b/.gitignore @@ -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 index 000000000..a21fee208 --- /dev/null +++ b/app/Jobs/HostingUpdate.php @@ -0,0 +1,63 @@ + ['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 index 124a2bdd6..000000000 --- a/resources/hosting/docker-compose.yml +++ /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 index 000000000..227c53443 --- /dev/null +++ b/resources/hosting/nginxproxy/config/custom_proxy_settings.conf @@ -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 index 000000000..579026a30 --- /dev/null +++ b/resources/hosting/nginxproxy/config/timeout.conf @@ -0,0 +1,4 @@ +proxy_connect_timeout 30; +proxy_send_timeout 30; +proxy_read_timeout 30; +send_timeout 30; diff --git a/resources/hosting/nginxproxy/docker-compose.yml b/resources/hosting/nginxproxy/docker-compose.yml index 4b631fe38..ada051e75 100644 --- a/resources/hosting/nginxproxy/docker-compose.yml +++ b/resources/hosting/nginxproxy/docker-compose.yml @@ -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: diff --git a/resources/hosting/nginxproxy/update b/resources/hosting/nginxproxy/update index 29cddbda5..b1082dd57 100644 --- a/resources/hosting/nginxproxy/update +++ b/resources/hosting/nginxproxy/update @@ -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 index 000000000..9e3745f50 --- /dev/null +++ b/resources/hosting/server/docker-compose.yml @@ -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 index 000000000..5e7dc4ff2 --- /dev/null +++ b/resources/hosting/server/update @@ -0,0 +1,5 @@ +#!/bin/sh +cd /docker/fluidbook-$hosting/server-$sid/ +docker-compose pull +docker-compose down +docker-compose up -d diff --git a/resources/hosting/updateall b/resources/hosting/updateall index 74733e326..c6be1abe6 100644 --- a/resources/hosting/updateall +++ b/resources/hosting/updateall @@ -1,4 +1,4 @@ #!/bin/sh docker network create fluidbook-$hosting -/docker/fluidbook-$hosting/nxginxproxy/update - +chmod 755 /docker/fluidbook-$hosting/*/update +$updateall