perf(docker): OPcache revalidate 調校 + composer 重裝條件修正 + nginx healthcheck 修復
Run Tests / test (pull_request) Successful in 1m56s
Run Tests / test (pull_request) Successful in 1m56s
實測修正根因:fpm 的 OPcache 本來就啟用(初版診斷是 CLI 假象), 真凶是 revalidate_freq=2 在 Windows bind mount 上每 2 秒重新 stat 全部腳本——窗口內 0.23s、窗口外 2.5s。 - local.ini:revalidate_freq 2→30、memory 192M、max_files 20000 (程式碼變更最多 30s 生效,立即生效用 kill -USR2 1 平滑重載) - entrypoint:composer 重裝改用 lock 內容比對,git 分支操作不再 觸發開機重裝(原 mtime 比對造成數分鐘 502 窗口) - healthcheck:localhost→127.0.0.1(busybox wget 先解析 ::1 而 nginx 只 listen IPv4,導致永遠 unhealthy) 驗收:穩態 0.20~0.27s(修復前 2.3~2.5s,約 10 倍);nginx healthy。 量測數據已寫回優化計畫文檔。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,9 +22,12 @@ php -r "
|
||||
file_put_contents('/var/www/.env', \$env);
|
||||
"
|
||||
|
||||
# Composer 依賴(vendor 不存在時才裝,通常已存在於 volume)
|
||||
if [ -f "composer.json" ] && { [ ! -d "vendor" ] || [ "composer.json" -nt "vendor/autoload.php" ]; }; then
|
||||
# Composer 依賴(vendor 不存在或 lock 內容變更時才裝)
|
||||
# 用內容比對而非 mtime:git checkout/pull 會更新 composer.json 的 mtime,
|
||||
# mtime 比對會讓每次分支操作後的開機都重跑 autoload 生成(bind mount 上耗時數分鐘、期間全站 502)
|
||||
if [ -f "composer.lock" ] && { [ ! -d "vendor" ] || ! cmp -s composer.lock vendor/.composer.lock.installed; }; then
|
||||
composer install --no-scripts --optimize-autoloader
|
||||
cp composer.lock vendor/.composer.lock.installed
|
||||
fi
|
||||
|
||||
# 背景執行:等 MySQL → migration → cache clear → storage link → swagger
|
||||
|
||||
Reference in New Issue
Block a user