chore: use test host database and redis in dev compose
This commit is contained in:
@@ -24,6 +24,8 @@ $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'],
|
||||
[$dockerfile, 'docker-php-ext-install', '本地 PHP 镜像必须安装 OPcache'],
|
||||
[$dockerfile, 'opcache', '本地 PHP 镜像必须安装 OPcache'],
|
||||
[$dockerfile, 'zz-opcache.ini', '本地 PHP 镜像必须载入 OPcache 配置'],
|
||||
@@ -33,6 +35,20 @@ $expectations = [
|
||||
[$uniappConfig, 'http://127.0.0.1:8000', 'H5 本地 API 应使用 IPv4 回环地址'],
|
||||
];
|
||||
|
||||
foreach (['mysql:', 'redis:'] as $removedService) {
|
||||
if (preg_match('/^ ' . preg_quote(rtrim($removedService, ':'), '/') . ':\s*$/m', $compose)) {
|
||||
fwrite(STDERR, "本地 compose 不应再启动 {$removedService} 服务\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (['depends_on:\n mysql:', 'depends_on:\n redis:'] as $removedDependency) {
|
||||
if (strpos($compose, $removedDependency) !== false) {
|
||||
fwrite(STDERR, "后端服务不应依赖已移除的本地服务\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($expectations as [$haystack, $needle, $message]) {
|
||||
if (strpos($haystack, $needle) === false) {
|
||||
fwrite(STDERR, $message . "\n");
|
||||
|
||||
Reference in New Issue
Block a user