Files
ulthon_admin/source/stack/docker-dev/docker-compose.yaml
augushong e0e2580646 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 扩展(框架作者需重建推送基础镜像)。
2026-08-09 09:07:10 +08:00

77 lines
2.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 一般不需要配置name默认是目录名但是如果你的系统中有同名的目录需要手动配置
# name: ulthon_admin
services:
ulthon_admin:
build:
context: ../../..
dockerfile: source/stack/docker-dev/Dockerfile
restart: unless-stopped
ports:
- "8000:8000"
volumes:
- ../../..:/var/www/html
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- XHPROF_ENABLE=${XHPROF_ENABLE:-false}
- XHGUI_UPLOAD_URL=http://xhgui:80/run/import
- XHGUI_UPLOAD_TOKEN=${XHGUI_UPLOAD_TOKEN:-ulthon-admin-xhprof}
depends_on:
mysql:
condition: service_healthy
mysql:
image: mysql:8.0
restart: unless-stopped
ports:
- "13306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ulthon
volumes:
- ../../../docker-dev-data/mysql:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
restart: unless-stopped
ports:
- "16379:6379"
volumes:
- ../../../docker-dev-data/redis:/data
phpmyadmin:
image: phpmyadmin:latest
restart: unless-stopped
ports:
- "18888:80"
environment:
PMA_HOST: mysql
depends_on:
mysql:
condition: service_healthy
xhgui:
image: xhgui/xhgui:0.24.x
restart: unless-stopped
profiles: ["xhprof"]
ports:
- "8142:80"
volumes:
# 挂载全局认证配置Basic Auth
- ../../../source/docker/xhgui-config.php:/var/www/xhgui/config/config.php
environment:
- XHGUI_UPLOAD_TOKEN=${XHGUI_UPLOAD_TOKEN:-ulthon-admin-xhprof}
# Basic Auth 认证(默认 admin/xhgui123通过 .env 或环境变量覆盖)
- XHGUI_AUTH_USER=${XHGUI_AUTH_USER:-admin}
- XHGUI_AUTH_PASS=${XHGUI_AUTH_PASS:-xhgui123}
depends_on:
mysql:
condition: service_healthy