mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 19:12:48 +08:00
增加docker配置;修复重置命令错误;优化timer请求机制支持本地
This commit is contained in:
67
Dockerfile
Normal file
67
Dockerfile
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# 基于官方 PHP 8.0 镜像
|
||||||
|
FROM php:8.0-fpm
|
||||||
|
|
||||||
|
# RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
||||||
|
# RUN sed -i 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
|
||||||
|
# 安装nginx
|
||||||
|
RUN apt-get install -y nginx
|
||||||
|
|
||||||
|
# 安装ffmpeg
|
||||||
|
RUN apt-get install -y ffmpeg
|
||||||
|
|
||||||
|
# 安装redis
|
||||||
|
RUN apt-get install -y redis-server
|
||||||
|
|
||||||
|
# 安装PHP扩展 zip
|
||||||
|
RUN apt-get install -y libzip-dev \
|
||||||
|
&& docker-php-ext-install zip
|
||||||
|
|
||||||
|
# 安装PHP扩展 mysql
|
||||||
|
RUN docker-php-ext-install mysqli pdo_mysql
|
||||||
|
|
||||||
|
# 安装PHP扩展 exif
|
||||||
|
RUN docker-php-ext-install exif
|
||||||
|
|
||||||
|
# 安装PHP扩展 imagemagick
|
||||||
|
RUN apt-get install -y libmagickwand-dev \
|
||||||
|
&& pecl install imagick \
|
||||||
|
&& docker-php-ext-enable imagick
|
||||||
|
|
||||||
|
# 安装PHP扩展 redis
|
||||||
|
RUN pecl install redis \
|
||||||
|
&& docker-php-ext-enable redis
|
||||||
|
|
||||||
|
# 安装PHP扩展 opcache
|
||||||
|
RUN docker-php-ext-install opcache
|
||||||
|
|
||||||
|
# 清理默认 Nginx 配置
|
||||||
|
RUN rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
|
# 设置工作目录
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# 将当前目录下的文件拷贝到工作目录
|
||||||
|
COPY . /var/www/html
|
||||||
|
|
||||||
|
# 创建runtime目录
|
||||||
|
RUN mkdir /var/www/html/runtime
|
||||||
|
|
||||||
|
# 设置runtime目录权限为777
|
||||||
|
RUN chmod -R 777 /var/www/html/runtime
|
||||||
|
|
||||||
|
# 创建持久化存储目录
|
||||||
|
VOLUME /var/www/html/runtime
|
||||||
|
|
||||||
|
# 暴露 Nginx 端口
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
#
|
||||||
|
RUN chmod +x /var/www/html/docker/run.sh
|
||||||
|
|
||||||
|
# 启动 Nginx PHP 然后阻塞
|
||||||
|
CMD /var/www/html/docker/run.sh
|
||||||
|
|
||||||
|
|
||||||
@@ -233,3 +233,6 @@ vscode中liveSassCompiler的配置:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### docker
|
||||||
|
内置了docker打包命令,打包出的镜像支持两种调用方法
|
||||||
30
docker/nginx.conf
Normal file
30
docker/nginx.conf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
root /var/www/html/public;
|
||||||
|
index index.php index.html index.htm;
|
||||||
|
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
# 上传大小不限制
|
||||||
|
client_max_body_size 8192m;
|
||||||
|
|
||||||
|
# 运行时长不限制
|
||||||
|
fastcgi_read_timeout 60000;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
if (!-e $request_filename) {
|
||||||
|
rewrite ^(.*)$ /index.php?s=$1 last; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
docker/phprun.ini
Normal file
11
docker/phprun.ini
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
; 内存不限制
|
||||||
|
memory_limit = -1
|
||||||
|
|
||||||
|
; 上传文件大小不限制
|
||||||
|
upload_max_filesize = -1
|
||||||
|
|
||||||
|
; 运行时长不限制
|
||||||
|
max_execution_time = 0
|
||||||
|
|
||||||
|
; POST大小不限制
|
||||||
|
post_max_size = -1
|
||||||
21
docker/run.sh
Normal file
21
docker/run.sh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# 将代码中的nginx复制到nginx配置文件中
|
||||||
|
cp /var/www/html/docker/nginx.conf /etc/nginx/sites-available/default
|
||||||
|
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
|
# 将代码中的php配置文件复制到php配置文件中
|
||||||
|
cp /var/www/html/docker/phprun.ini /usr/local/etc/php/conf.d
|
||||||
|
|
||||||
|
# 运行redis
|
||||||
|
nohup redis-server --requirepass "" &
|
||||||
|
# 运行定时任务
|
||||||
|
nohup php /var/www/html/think timer --local &
|
||||||
|
|
||||||
|
# 如果第一个参数是server,或者没有参数,则运行server
|
||||||
|
if [ "$1" = "server" ] || [ "$1" = "" ]; then
|
||||||
|
# 运行nginx
|
||||||
|
service nginx start
|
||||||
|
# 运行php-fpm
|
||||||
|
php-fpm
|
||||||
|
else
|
||||||
|
php "/var/www/html/""$@"
|
||||||
|
fi
|
||||||
@@ -348,6 +348,7 @@ class AdminUpdateServiceBase
|
|||||||
'app',
|
'app',
|
||||||
'config',
|
'config',
|
||||||
'route',
|
'route',
|
||||||
|
'docker'
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($optional_files_prefix as $prefix) {
|
foreach ($optional_files_prefix as $prefix) {
|
||||||
@@ -356,7 +357,7 @@ class AdminUpdateServiceBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果file_path不存在目录分隔符,则是可选更新的文件
|
// 如果file_path不存在目录分隔符,则是可选更新的文件(根目录下的文件)
|
||||||
if (strpos($file_path, '/') === false) {
|
if (strpos($file_path, '/') === false) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ class TimerBase extends Command
|
|||||||
$this->setName('timer')
|
$this->setName('timer')
|
||||||
->addOption('temp', null, Option::VALUE_NONE)
|
->addOption('temp', null, Option::VALUE_NONE)
|
||||||
->addOption('quit', null, Option::VALUE_NONE)
|
->addOption('quit', null, Option::VALUE_NONE)
|
||||||
|
->addOption('local', null, Option::VALUE_NONE)
|
||||||
|
->addOption('local-host', null, Option::VALUE_OPTIONAL, '本地域名','http://localhost')
|
||||||
|
->addOption('local-port', null, Option::VALUE_OPTIONAL, '本地端口', '80')
|
||||||
->setDescription('内置秒级定时器');
|
->setDescription('内置秒级定时器');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,16 +33,23 @@ class TimerBase extends Command
|
|||||||
$output->writeln('start timer');
|
$output->writeln('start timer');
|
||||||
|
|
||||||
$site_domain = sysconfig('site', 'site_domain');
|
$site_domain = sysconfig('site', 'site_domain');
|
||||||
|
|
||||||
if (empty($site_domain)) {
|
if (empty($site_domain)) {
|
||||||
$output->writeln('请前往后台设置站点域名(site_domain)配置项');
|
$output->writeln('请前往后台设置站点域名(site_domain)配置项');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$output->writeln('站点域名:' . $site_domain);
|
$output->writeln('站点域名:' . $site_domain);
|
||||||
|
$host = $site_domain;
|
||||||
|
|
||||||
|
if ($input->hasOption('local')) {
|
||||||
|
$host = $input->getOption('local-host') . ':' . $input->getOption('local-port');
|
||||||
|
}
|
||||||
|
|
||||||
$client = new Client([
|
$client = new Client([
|
||||||
'base_uri' => $site_domain,
|
'base_uri' => $host,
|
||||||
|
'headers' => [
|
||||||
|
'Host' => $site_domain,
|
||||||
|
],
|
||||||
'verify' => false,
|
'verify' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -52,14 +62,12 @@ class TimerBase extends Command
|
|||||||
$config_item = static::initConfigItem($config_item);
|
$config_item = static::initConfigItem($config_item);
|
||||||
|
|
||||||
$name = $config_item['name'];
|
$name = $config_item['name'];
|
||||||
|
|
||||||
if ($name == 'http_demo' && !env('adminsystem.is_demo', false)) {
|
if ($name == 'http_demo' && !env('adminsystem.is_demo', false)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache_key = 'timer_' . $name;
|
$cache_key = 'timer_' . $name;
|
||||||
$cache_tag = 'system_timer';
|
$cache_tag = 'system_timer';
|
||||||
|
|
||||||
$last_exec_time = Cache::get($cache_key, 0);
|
$last_exec_time = Cache::get($cache_key, 0);
|
||||||
|
|
||||||
if ($last_exec_time >= time() - $config_item['frequency']) {
|
if ($last_exec_time >= time() - $config_item['frequency']) {
|
||||||
@@ -67,9 +75,7 @@ class TimerBase extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cache::tag($cache_tag)->set($cache_key, time());
|
Cache::tag($cache_tag)->set($cache_key, time());
|
||||||
|
|
||||||
$type = $config_item['type'];
|
$type = $config_item['type'];
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'site':
|
case 'site':
|
||||||
$output->writeln(date('Y-m-d H:i:s') . ': build site request async:' . $config_item['target']);
|
$output->writeln(date('Y-m-d H:i:s') . ': build site request async:' . $config_item['target']);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ResetPasswordBase extends TimerController
|
|||||||
return $this->error('本功能只有在演示环境下在能使用', '', '/');
|
return $this->error('本功能只有在演示环境下在能使用', '', '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = Console::call('admin:resetPassword', [
|
$output = Console::call('admin:reset:password', [
|
||||||
'--password=123456',
|
'--password=123456',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user