fix: connect docker php to host-only test database
This commit is contained in:
@@ -6,6 +6,7 @@ $files = [
|
||||
'compose' => $root . '/docker/docker-compose.dev.yml',
|
||||
'php_dockerfile' => $root . '/docker/Dockerfile.php',
|
||||
'opcache_ini' => $root . '/docker/config/php/conf.d/zz-opcache.ini',
|
||||
'nginx_config' => $root . '/docker/config/nginx/conf.d/sport-era.dev.conf',
|
||||
'uniapp_config' => $root . '/uniapp/src/config/index.ts',
|
||||
];
|
||||
|
||||
@@ -19,19 +20,22 @@ foreach ($files as $label => $path) {
|
||||
$compose = file_get_contents($files['compose']);
|
||||
$dockerfile = file_get_contents($files['php_dockerfile']);
|
||||
$opcacheIni = file_get_contents($files['opcache_ini']);
|
||||
$nginxConfig = file_get_contents($files['nginx_config']);
|
||||
$uniappConfig = file_get_contents($files['uniapp_config']);
|
||||
|
||||
$expectations = [
|
||||
[$compose, 'sport-era-dev-php:local', 'server 和 scheduler 应使用本地 PHP 镜像'],
|
||||
[$compose, 'docker/Dockerfile.php', '本地 PHP 镜像应由 Dockerfile 构建'],
|
||||
[$compose, './.env.server:/likeadmin_php/server/.env:ro', 'Docker 后端应使用独立的服务器环境文件'],
|
||||
[$compose, 'host.docker.internal:host-gateway', 'Docker 后端应能访问宿主机上的数据库与 Redis'],
|
||||
[$compose, 'network_mode: host', 'Docker 后端应使用宿主机网络访问仅允许本机连接的测试数据库'],
|
||||
[$dockerfile, 'docker-php-ext-install', '本地 PHP 镜像必须安装 OPcache'],
|
||||
[$dockerfile, '0.0.0.0:9000', 'PHP-FPM 应允许 Nginx 容器通过宿主机网络访问'],
|
||||
[$dockerfile, 'opcache', '本地 PHP 镜像必须安装 OPcache'],
|
||||
[$dockerfile, 'zz-opcache.ini', '本地 PHP 镜像必须载入 OPcache 配置'],
|
||||
[$opcacheIni, 'opcache.enable=1', 'OPcache 必须启用'],
|
||||
[$opcacheIni, 'opcache.validate_timestamps=1', '开发环境必须保留源码更新时间检测'],
|
||||
[$opcacheIni, 'opcache.revalidate_freq=0', '源码修改必须立即使 OPcache 失效'],
|
||||
[$nginxConfig, 'fastcgi_pass host.docker.internal:9000', 'Nginx 应通过宿主机网关访问 host 网络 PHP-FPM'],
|
||||
[$uniappConfig, 'http://127.0.0.1:8000', 'H5 本地 API 应使用 IPv4 回环地址'],
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user