From e45c67a69abe8e7c607acdc07973bd2277602887 Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 11:03:30 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B0ThinkPHP8=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81PHP8=E7=9A=84=E6=96=B0=E7=89=B9=E6=80=A7?= =?UTF-8?q?=E4=BB=A5=E5=8F=8Aopcache=20jit=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index c24415b..3fa3e20 100644 --- a/composer.json +++ b/composer.json @@ -17,13 +17,14 @@ { "name": "yunwuxin", "email": "448901948@qq.com" - } + } ], "require": { - "php": ">=7.2.5", - "topthink/framework": "^6.0.0", - "topthink/think-orm": "^2.0", - "topthink/think-view": "^1.0", + "php": ">=8.0.0", + "topthink/framework": "^8.0", + "topthink/think-orm": "^3.0", + "topthink/think-filesystem": "^2.0", + "topthink/think-view": "^2.0", "cccyun/think-captcha": "^3.0" }, "require-dev": { From 49335ad3473a45c6dd8078afa2c7c51aea1a338b Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 13:47:28 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B0ThinkPHP8=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81PHP8=E7=9A=84=E6=96=B0=E7=89=B9=E6=80=A7?= =?UTF-8?q?=E4=BB=A5=E5=8F=8Aopcache=20jit=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 97 ++++++++++++++++++++++++++------------------------- vercel.json | 15 ++++++++ 2 files changed, 64 insertions(+), 48 deletions(-) create mode 100644 vercel.json diff --git a/composer.json b/composer.json index 3fa3e20..9296358 100644 --- a/composer.json +++ b/composer.json @@ -1,52 +1,53 @@ { - "name": "topthink/think", - "description": "the new thinkphp framework", - "type": "project", - "keywords": [ - "framework", - "thinkphp", - "ORM" - ], - "homepage": "https://www.thinkphp.cn/", - "license": "Apache-2.0", - "authors": [ - { - "name": "liu21st", - "email": "liu21st@gmail.com" - }, - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "require": { - "php": ">=8.0.0", - "topthink/framework": "^8.0", - "topthink/think-orm": "^3.0", - "topthink/think-filesystem": "^2.0", - "topthink/think-view": "^2.0", - "cccyun/think-captcha": "^3.0" + "name": "topthink/think", + "description": "the new thinkphp framework", + "type": "project", + "keywords": [ + "framework", + "thinkphp", + "ORM" + ], + "homepage": "https://www.thinkphp.cn/", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" }, - "require-dev": { - "symfony/var-dumper": "^4.2", - "topthink/think-trace":"^1.0", - "swoole/ide-helper": "^5.1" - }, - "autoload": { - "psr-4": { - "app\\": "app" - }, - "psr-0": { - "": "extend/" - } - }, - "config": { - "preferred-install": "dist" - }, - "scripts": { - "post-autoload-dump": [ - "@php think service:discover", - "@php think vendor:publish" - ] + { + "name": "yunwuxin", + "email": "448901948@qq.com" } + ], + "require": { + "php": ">=8.0.0", + "topthink/framework": "^8.0", + "topthink/think-orm": "^3.0", + "topthink/think-filesystem": "^2.0", + "topthink/think-view": "^2.0", + "cccyun/think-captcha": "^3.0", + "ext-pdo": "*" + }, + "require-dev": { + "symfony/var-dumper": "^4.2", + "topthink/think-trace": "^1.0", + "swoole/ide-helper": "^5.1" + }, + "autoload": { + "psr-4": { + "app\\": "app" + }, + "psr-0": { + "": "extend/" + } + }, + "config": { + "preferred-install": "dist" + }, + "scripts": { + "post-autoload-dump": [ + "@php think service:discover", + "@php think vendor:publish" + ] + } } diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..c8cadfd --- /dev/null +++ b/vercel.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "builds": [ + { + "src": "public/index.php", + "use": "@vercel/php" + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "public/index.php" + } + ] +} From 7768140a302f818f4b9b60db9f852cdc8baee9a2 Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 13:47:28 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E4=BF=AE=E8=A1=A5=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E7=9A=84=E4=BE=9D=E8=B5=96=20=E6=B7=BB=E5=8A=A0vercel=E9=83=A8?= =?UTF-8?q?=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 97 ++++++++++++++++++++++++++------------------------- vercel.json | 15 ++++++++ 2 files changed, 64 insertions(+), 48 deletions(-) create mode 100644 vercel.json diff --git a/composer.json b/composer.json index 3fa3e20..9296358 100644 --- a/composer.json +++ b/composer.json @@ -1,52 +1,53 @@ { - "name": "topthink/think", - "description": "the new thinkphp framework", - "type": "project", - "keywords": [ - "framework", - "thinkphp", - "ORM" - ], - "homepage": "https://www.thinkphp.cn/", - "license": "Apache-2.0", - "authors": [ - { - "name": "liu21st", - "email": "liu21st@gmail.com" - }, - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "require": { - "php": ">=8.0.0", - "topthink/framework": "^8.0", - "topthink/think-orm": "^3.0", - "topthink/think-filesystem": "^2.0", - "topthink/think-view": "^2.0", - "cccyun/think-captcha": "^3.0" + "name": "topthink/think", + "description": "the new thinkphp framework", + "type": "project", + "keywords": [ + "framework", + "thinkphp", + "ORM" + ], + "homepage": "https://www.thinkphp.cn/", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" }, - "require-dev": { - "symfony/var-dumper": "^4.2", - "topthink/think-trace":"^1.0", - "swoole/ide-helper": "^5.1" - }, - "autoload": { - "psr-4": { - "app\\": "app" - }, - "psr-0": { - "": "extend/" - } - }, - "config": { - "preferred-install": "dist" - }, - "scripts": { - "post-autoload-dump": [ - "@php think service:discover", - "@php think vendor:publish" - ] + { + "name": "yunwuxin", + "email": "448901948@qq.com" } + ], + "require": { + "php": ">=8.0.0", + "topthink/framework": "^8.0", + "topthink/think-orm": "^3.0", + "topthink/think-filesystem": "^2.0", + "topthink/think-view": "^2.0", + "cccyun/think-captcha": "^3.0", + "ext-pdo": "*" + }, + "require-dev": { + "symfony/var-dumper": "^4.2", + "topthink/think-trace": "^1.0", + "swoole/ide-helper": "^5.1" + }, + "autoload": { + "psr-4": { + "app\\": "app" + }, + "psr-0": { + "": "extend/" + } + }, + "config": { + "preferred-install": "dist" + }, + "scripts": { + "post-autoload-dump": [ + "@php think service:discover", + "@php think vendor:publish" + ] + } } diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..c8cadfd --- /dev/null +++ b/vercel.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "builds": [ + { + "src": "public/index.php", + "use": "@vercel/php" + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "public/index.php" + } + ] +} From 00233a60a5dcc88d87936fad2d44cb6e77521737 Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 13:53:45 +0800 Subject: [PATCH 04/13] =?UTF-8?q?Revert=20"=E6=9B=B4=E6=96=B0=E5=88=B0Thin?= =?UTF-8?q?kPHP8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 49335ad3473a45c6dd8078afa2c7c51aea1a338b. --- composer.json | 95 +++++++++++++++++++++++++-------------------------- vercel.json | 15 -------- 2 files changed, 47 insertions(+), 63 deletions(-) delete mode 100644 vercel.json diff --git a/composer.json b/composer.json index 9296358..3fa3e20 100644 --- a/composer.json +++ b/composer.json @@ -1,53 +1,52 @@ { - "name": "topthink/think", - "description": "the new thinkphp framework", - "type": "project", - "keywords": [ - "framework", - "thinkphp", - "ORM" - ], - "homepage": "https://www.thinkphp.cn/", - "license": "Apache-2.0", - "authors": [ - { - "name": "liu21st", - "email": "liu21st@gmail.com" + "name": "topthink/think", + "description": "the new thinkphp framework", + "type": "project", + "keywords": [ + "framework", + "thinkphp", + "ORM" + ], + "homepage": "https://www.thinkphp.cn/", + "license": "Apache-2.0", + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + }, + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "require": { + "php": ">=8.0.0", + "topthink/framework": "^8.0", + "topthink/think-orm": "^3.0", + "topthink/think-filesystem": "^2.0", + "topthink/think-view": "^2.0", + "cccyun/think-captcha": "^3.0" }, - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "require": { - "php": ">=8.0.0", - "topthink/framework": "^8.0", - "topthink/think-orm": "^3.0", - "topthink/think-filesystem": "^2.0", - "topthink/think-view": "^2.0", - "cccyun/think-captcha": "^3.0", - "ext-pdo": "*" - }, - "require-dev": { - "symfony/var-dumper": "^4.2", - "topthink/think-trace": "^1.0", - "swoole/ide-helper": "^5.1" - }, - "autoload": { - "psr-4": { - "app\\": "app" + "require-dev": { + "symfony/var-dumper": "^4.2", + "topthink/think-trace":"^1.0", + "swoole/ide-helper": "^5.1" }, - "psr-0": { - "": "extend/" + "autoload": { + "psr-4": { + "app\\": "app" + }, + "psr-0": { + "": "extend/" + } + }, + "config": { + "preferred-install": "dist" + }, + "scripts": { + "post-autoload-dump": [ + "@php think service:discover", + "@php think vendor:publish" + ] } - }, - "config": { - "preferred-install": "dist" - }, - "scripts": { - "post-autoload-dump": [ - "@php think service:discover", - "@php think vendor:publish" - ] - } } diff --git a/vercel.json b/vercel.json deleted file mode 100644 index c8cadfd..0000000 --- a/vercel.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": 2, - "builds": [ - { - "src": "public/index.php", - "use": "@vercel/php" - } - ], - "routes": [ - { - "src": "/(.*)", - "dest": "public/index.php" - } - ] -} From 5e25fb2726e3ecdce5c4d087bb54c7a57bb48d7a Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 14:07:37 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E4=BF=AE=E8=A1=A5=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E7=9A=84=E4=BE=9D=E8=B5=96=EF=BC=8C=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=AE=89=E8=A3=85=E9=95=9C=E5=83=8F=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composer.json b/composer.json index 3fa3e20..d859334 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ ], "require": { "php": ">=8.0.0", + "ext-pdo": "*", "topthink/framework": "^8.0", "topthink/think-orm": "^3.0", "topthink/think-filesystem": "^2.0", @@ -48,5 +49,11 @@ "@php think service:discover", "@php think vendor:publish" ] + }, + "repositories": { + "packagist": { + "type": "composer", + "url": "https://mirrors.aliyun.com/composer/" + } } } From 45c0f0f0b56cc8a18cb61498f94b34a02a56655a Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 14:07:53 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 12 ++++++++++++ dockerfile | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 docker-compose.yml create mode 100644 dockerfile diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..150dc42 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.8' + +services: + php: + build: + context: . + dockerfile: Dockerfile + volumes: + - .:/var/www/html # 将当前目录挂载到容器 + command: php think run # 启动 PHP 内置服务器 + ports: + - "8000:8000" # 映射容器端口到主机端口 diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..693b248 --- /dev/null +++ b/dockerfile @@ -0,0 +1,22 @@ +# 使用 PHP 8.1 镜像 +FROM php:8.1-cli + +# 安装 OPcache 扩展 +RUN apt-get update && apt-get install -y libzip-dev \ + && docker-php-ext-install opcache \ + && docker-php-ext-install pdo pdo_mysql + +# 拷贝项目文件到容器 +COPY . /var/www/html/ + +# 设置工作目录 +WORKDIR /var/www/html/ + +# 安装 Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# 安装项目依赖 +RUN composer install --no-interaction + +# 配置 OPcache +COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini From 82246fd12b63715cb08a4e777cabc58ebe6a1ad0 Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 14:08:17 +0800 Subject: [PATCH 07/13] =?UTF-8?q?opcache=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opcache.ini | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 opcache.ini diff --git a/opcache.ini b/opcache.ini new file mode 100644 index 0000000..35ec3c0 --- /dev/null +++ b/opcache.ini @@ -0,0 +1,10 @@ +; Enable OPcache extension +opcache.enable = 1 +opcache.memory_consumption=128 +opcache.interned_strings_buffer=32 +opcache.max_accelerated_files=80000 +opcache.revalidate_freq=3 +opcache.fast_shutdown=1 +opcache.enable_cli=1 +opcache.jit_buffer_size=128m +opcache.jit=1205 From 9c4d201aeb64f45eecf3044d5cea8fad6aed274d Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 14:08:28 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/Install.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/app/controller/Install.php b/app/controller/Install.php index 0b0ceb9..c3dcae4 100644 --- a/app/controller/Install.php +++ b/app/controller/Install.php @@ -1,11 +1,12 @@ isPost()){ - $mysql_host = input('post.mysql_host', null, 'trim'); - $mysql_port = intval(input('post.mysql_port', '3306')); - $mysql_user = input('post.mysql_user', null, 'trim'); - $mysql_pwd = input('post.mysql_pwd', null, 'trim'); - $mysql_name = input('post.mysql_name', null, 'trim'); - $mysql_prefix = input('post.mysql_prefix', 'cloud_', 'trim'); - $admin_username = input('post.admin_username', null, 'trim'); - $admin_password = input('post.admin_password', null, 'trim'); + $mysql_host = Request::post('mysql_host'); + $mysql_port = intval(Request::post('mysql_port', '3306')); + $mysql_user = Request::post('mysql_user', null, 'trim'); + $mysql_pwd = Request::post('mysql_pwd', null, 'trim'); + $mysql_name = Request::post('mysql_name', null, 'trim'); + $mysql_prefix = Request::post('mysql_prefix', 'cloud_', 'trim'); + $admin_username = Request::post('admin_username', null, 'trim'); + $admin_password = Request::post('admin_password', null, 'trim'); if(!$mysql_host || !$mysql_user || !$mysql_pwd || !$mysql_name || !$admin_username || !$admin_password){ return json(['code'=>0, 'msg'=>'必填项不能为空']); } - $configdata = file_get_contents(app()->getRootPath().'.example.env'); - $configdata = str_replace(['{dbhost}','{dbname}','{dbuser}','{dbpwd}','{dbport}','{dbprefix}'], [$mysql_host, $mysql_name, $mysql_user, $mysql_pwd, $mysql_port, $mysql_prefix], $configdata); + $configData = file_get_contents(app()->getRootPath().'.example.env'); + $configData = str_replace(['{dbhost}','{dbname}','{dbuser}','{dbpwd}','{dbport}','{dbprefix}'], [$mysql_host, $mysql_name, $mysql_user, $mysql_pwd, $mysql_port, $mysql_prefix], $configData); try{ + $DB = Db::connect(); $DB=new PDO("mysql:host=".$mysql_host.";dbname=".$mysql_name.";port=".$mysql_port,$mysql_user,$mysql_pwd); }catch(Exception $e){ if($e->getCode() == 2002){ @@ -56,7 +58,9 @@ class Install extends BaseController $sqls[]="REPLACE INTO `".$mysql_prefix."config` VALUES ('sys_key', '".random(16)."')"; $sqls[]="INSERT INTO `".$mysql_prefix."user` (`username`,`password`,`level`,`regtime`,`lasttime`,`status`) VALUES ('".addslashes($admin_username)."', '$password', 2, NOW(), NOW(), 1)"; - $success=0;$error=0;$errorMsg=null; + $success = 0; + $error = 0; + $errorMsg = null; foreach ($sqls as $value) { $value=trim($value); if(empty($value))continue; @@ -70,7 +74,7 @@ class Install extends BaseController } } if(empty($errorMsg)){ - if(!file_put_contents(app()->getRootPath().'.env', $configdata)){ + if(!file_put_contents(app()->getRootPath().'.env', $configData)){ return json(['code'=>0, 'msg'=>'保存失败,请确保网站根目录有写入权限']); } Cache::clear(); From 98b555e80005eceb5c8fffdfc8eb4d3d947f8bfa Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 18:42:07 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E4=B8=8D=E6=94=AF=E6=8C=81compose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 12 ------------ scripts/supervisord.conf | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 docker-compose.yml create mode 100644 scripts/supervisord.conf diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 150dc42..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '3.8' - -services: - php: - build: - context: . - dockerfile: Dockerfile - volumes: - - .:/var/www/html # 将当前目录挂载到容器 - command: php think run # 启动 PHP 内置服务器 - ports: - - "8000:8000" # 映射容器端口到主机端口 diff --git a/scripts/supervisord.conf b/scripts/supervisord.conf new file mode 100644 index 0000000..4fbea2d --- /dev/null +++ b/scripts/supervisord.conf @@ -0,0 +1,14 @@ +[supervisord] +nodaemon=true + +[program:web] +command=php /app/think run +autostart=true +autorestart=true + +[program:check_tasks] +command=/app/scripts/run_tasks.sh +autostart=true +autorestart=true +startretries=99999 ; 设置为一个很大的值 +startsecs=5 ; 启动后等待时间 \ No newline at end of file From 92c9faac20e23021bd395bc50eac1ebb85b67c59 Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 18:42:29 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E8=B0=83=E8=AF=95=E5=88=B0=E6=9C=80?= =?UTF-8?q?=E7=BB=88=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dockerfile | 66 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/dockerfile b/dockerfile index 693b248..1903a28 100644 --- a/dockerfile +++ b/dockerfile @@ -1,22 +1,56 @@ -# 使用 PHP 8.1 镜像 -FROM php:8.1-cli +# 使用 php:8.1.30-cli-alpine3.20 作为基础镜像 +FROM php:8.1.30-cli-alpine3.20 -# 安装 OPcache 扩展 -RUN apt-get update && apt-get install -y libzip-dev \ - && docker-php-ext-install opcache \ - && docker-php-ext-install pdo pdo_mysql +# 更改为阿里云的 Alpine 软件源并更新索引 +RUN sed -i 's|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g' /etc/apk/repositories \ + && apk update \ + && apk add --no-cache \ + supervisor \ + curl \ + bash \ + libzip-dev \ + libpng-dev \ + freetype-dev \ + libjpeg-turbo-dev \ + libwebp-dev \ + libxpm-dev \ + libavif-dev \ + gcc \ + g++ \ + make \ + autoconf \ + libc-dev \ + openssl-dev \ + libaio-dev \ + linux-headers \ + brotli-dev -# 拷贝项目文件到容器 -COPY . /var/www/html/ +RUN docker-php-ext-configure gd --with-jpeg --with-webp --with-xpm --with-avif --with-freetype=/usr/include/freetype2 --with-jpeg=/usr/include\ + && docker-php-ext-install gd \ + && docker-php-ext-install zip \ + && docker-php-ext-install pdo pdo_mysql \ + && docker-php-ext-enable opcache \ + && pecl install swoole \ + && docker-php-ext-enable swoole \ + && rm -rf /var/cache/apk/* +# 将应用程序代码复制到容器中 +COPY . /app # 设置工作目录 -WORKDIR /var/www/html/ - -# 安装 Composer +WORKDIR /app +# 安装composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer - # 安装项目依赖 -RUN composer install --no-interaction - -# 配置 OPcache -COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini +RUN composer install --no-interaction --no-dev --optimize-autoloader +# 暴露端口 +EXPOSE 8000 +# 复制计划任务配置文件 +COPY scripts/opiptask /etc/crontabs/root +# 复制进程守护配置文件 +COPY scripts/supervisord.conf /etc/supervisord.conf +# 授权启动脚本 +RUN chmod +x /app/scripts/run_tasks.sh +# 复制opcache配置文件 +COPY scripts/opcache.ini /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini +# 运行进程守护应用 +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] From 4197c7609f149593dd720351895216965893d82c Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 18:42:51 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E4=BB=A5=E5=8F=8APHP=E9=85=8D=E7=BD=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opcache.ini => scripts/opcache.ini | 1 + scripts/opiptask | 1 + scripts/run_tasks.sh | 15 +++++++++++++++ 3 files changed, 17 insertions(+) rename opcache.ini => scripts/opcache.ini (92%) create mode 100644 scripts/opiptask create mode 100644 scripts/run_tasks.sh diff --git a/opcache.ini b/scripts/opcache.ini similarity index 92% rename from opcache.ini rename to scripts/opcache.ini index 35ec3c0..be2890f 100644 --- a/opcache.ini +++ b/scripts/opcache.ini @@ -1,3 +1,4 @@ +zend_extension=opcache ; Enable OPcache extension opcache.enable = 1 opcache.memory_consumption=128 diff --git a/scripts/opiptask b/scripts/opiptask new file mode 100644 index 0000000..d68e460 --- /dev/null +++ b/scripts/opiptask @@ -0,0 +1 @@ +*/15 * * * * php /app/think opiptask >> /var/log/cron.log 2>&1 \ No newline at end of file diff --git a/scripts/run_tasks.sh b/scripts/run_tasks.sh new file mode 100644 index 0000000..c936bf8 --- /dev/null +++ b/scripts/run_tasks.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# 检查文件是否存在 +if [ -f "/app/.env" ]; then + echo "已安装网站, 开始执行计划任务和进程守护." + + # 启动 crond + /usr/sbin/crond + + # 启动 dmtask + php /app/think dmtask +else + echo "未安装网站, 跳过计划任务和进程守护." + exit 0 +fi From a22ecd53d695299d5dcd580f9ede7951d23aa9ec Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 19:19:18 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AE=80=E4=BB=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 85 ++++++------------------------------------------------- 1 file changed, 8 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index fec5066..7bbb12b 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ CF优选IP功能,添加优选IP任务 ### 部署方法 -* 从[Release](https://github.com/netcccyun/dnsmgr/releases)页面下载安装包 +* 从[GitHub](https://github.com/coolxitech/dnsmgr)页面下载源码 -* 运行环境要求PHP7.4+,MySQL5.6+ +* 运行环境要求PHP8.0+,MySQL5.6+ * 设置网站运行目录为`public` @@ -84,86 +84,17 @@ location / { ``` ### Docker部署方法 +非原仓镜像,仅运行网站服务,数据库服务需要自行创建。 -首先需要安装Docker,然后执行以下命令拉取镜像并启动(启动后监听8081端口): +容器使用本地数据库需要获取Docker网络主机IP地址且不能使用`127.0.0.1`和`localhost`,一般默认是`172.17.0.1`。 + +首先需要安装Docker,然后执行以下命令拉取镜像并启动(启动后监听8000端口): ``` -docker run --name dnsmgr -dit -p 8081:80 -v /var/dnsmgr:/app/www netcccyun/dnsmgr +docker run --name dnsmgr -dit -p 8000:8000 -v /var/dnsmgr:/app kpxyyyy/dnsmgr ``` - -访问并安装好后如果容灾切换未自动启动,重启容器即可: - -``` -docker restart dnsmgr -``` - -### docker-compose部署方法 - -``` -version: '3' -services: - dnsmgr-web: - container_name: dnsmgr-web - stdin_open: true - tty: true - ports: - - 8081:80 - volumes: - - /volume1/docker/dnsmgr/web:/app/www - image: netcccyun/dnsmgr - depends_on: - - dnsmgr-mysql - networks: - - dnsmgr-network - - dnsmgr-mysql: - container_name: dnsmgr-mysql - restart: always - ports: - - 3306:3306 - volumes: - - ./mysql/conf/my.cnf:/etc/mysql/my.cnf - - ./mysql/logs:/logs - - ./mysql/data:/var/lib/mysql - environment: - - MYSQL_ROOT_PASSWORD=123456 - - TZ=Asia/Shanghai - image: mysql:5.7 - networks: - - dnsmgr-network - -networks: - dnsmgr-network: - driver: bridge -``` - -在运行之前请创建好目录 -``` -mkdir -p ./web -mkdir -p ./mysql/conf -mkdir -p ./mysql/logs -mkdir -p ./mysql/data - -vim mysql/conf/my.cnf -[mysqld] -sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION -``` - -登陆mysql容器创建数据库 -``` -docker exec -it dnsmgr-mysql /bin/bash -mysql -uroot -p123456 -create database dnsmgr; -``` - -在install界面链接IP填写dnsmgr-mysql - +推荐使用Nginx进行反向代理. ### 版权信息 版权所有Copyright © 2023~2024 by 消失的彩虹海(https://blog.cccyun.cn) -### 其他推荐 - -- [彩虹云主机 - 免备案CDN/虚拟主机](https://www.cccyun.net/) -- [小白云高防云服务器](https://www.xiaobaiyun.cn/aff/GMLPMFOV) - From 5cbdcb9bf7bc3467c4d106f58df2fb9b9d8cb7ba Mon Sep 17 00:00:00 2001 From: coolxitech Date: Tue, 29 Oct 2024 19:27:26 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/supervisord.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/supervisord.conf b/scripts/supervisord.conf index 4fbea2d..a2ac295 100644 --- a/scripts/supervisord.conf +++ b/scripts/supervisord.conf @@ -7,7 +7,7 @@ autostart=true autorestart=true [program:check_tasks] -command=/app/scripts/run_tasks.sh +command=bash /app/scripts/run_tasks.sh autostart=true autorestart=true startretries=99999 ; 设置为一个很大的值