mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-08-30 12:45:32 +08:00
feat(stack): 所有 Docker 模式集成 XHProf 性能分析
在 docker-dev/docker-dev-sync/docker-serve/full 四个模式中集成 XHProf 性能分析能力,默认不启用(--profile xhprof 按需开启),零侵入不改 业务代码和 run.sh。 核心组件: - source/docker/xhprof-bootstrap.php: 采集器初始化(auto_prepend_file) - source/docker/xhgui-config.php: XHGui 认证配置(Basic Auth)+ PDO 存储 - 各 Dockerfile: 安装 PECL xhprof 扩展 + php-profiler 到 /opt/xhprof/ - 各 docker-compose: 新增 xhgui 服务(profiles: xhprof),端口 8142 存储方案:PDO MySQL(复用现有 MySQL),避免 MongoDB PHP 驱动兼容性问题。 docker-dev/docker-dev-sync 开箱即用;docker-serve/full 需配置 XHGUI_PDO_DSN。 认证:HTTP Basic Auth,默认 admin/xhgui123,环境变量可覆盖。 采集控制:XHPROF_ENABLE 环境变量 + cookie _profiler 强制触发 + 1% 采样。 Dockerfile.base 同步新增 xhprof 扩展(框架作者需重建推送基础镜像)。
This commit is contained in:
@@ -27,6 +27,7 @@ RUN install-php-extensions imagick
|
||||
RUN install-php-extensions zip
|
||||
RUN install-php-extensions pcntl
|
||||
RUN install-php-extensions xdebug
|
||||
RUN install-php-extensions xhprof
|
||||
|
||||
# Clean default Nginx config
|
||||
RUN rm /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
|
||||
@@ -62,6 +63,17 @@ RUN rm -rf /var/www/html/source/docker && ln -sf /var/www/html/source/stack/dock
|
||||
# Generate autoloader (without --no-dev optimizations)
|
||||
RUN composer dump-autoload
|
||||
|
||||
# XHProf: 安装 php-profiler 到独立目录(避免 rsync 同步覆盖)
|
||||
RUN mkdir -p /opt/xhprof \
|
||||
&& cd /opt/xhprof \
|
||||
&& composer require perftools/php-profiler
|
||||
|
||||
# XHProf: 复制采集器 bootstrap(全局配置,不受 rsync 同步影响)
|
||||
COPY source/docker/xhprof-bootstrap.php /opt/xhprof/xhprof-bootstrap.php
|
||||
|
||||
# XHProf: 配置 auto_prepend_file(zzz 前缀确保最后加载)
|
||||
RUN echo 'auto_prepend_file = /opt/xhprof/xhprof-bootstrap.php' > /usr/local/etc/php/conf.d/zzz-xhprof.ini
|
||||
|
||||
# Internal install composer and dependencies, comment out if not needed
|
||||
# RUN install-php-extensions @composer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user