fix(stack): 其余4个模式同步 bind mount 兼容修复

与 docker-dev(commit 5797885)保持一致的修复方案:
- run.sh 改为 SCRIPT_DIR 自动检测脚本所在目录
- Dockerfile ENTRYPOINT/chmod 改为完整路径
  /var/www/html/source/stack/<mode>/source/docker/run.sh
- 基础配置(nginx.conf/zz-phprun.ini/zz-phpfpm.conf)复制到各模式目录
- ln -s 改为 ln -sf(防止容器重启时 File exists)

docker-dev-sync 额外保留 sync.sh 调用逻辑(init + watch),
仅路径改为 \/sync.sh
This commit is contained in:
augushong
2026-07-22 23:40:33 +08:00
parent 5797885f3d
commit 544604ebff
20 changed files with 300 additions and 28 deletions

View File

@@ -80,10 +80,11 @@ VOLUME /var/www/html/storage
# Expose Nginx port
EXPOSE 8000
RUN chmod +x /var/www/html/source/docker/sync.sh
RUN chmod +x /var/www/html/source/docker/run.sh
# B-route bind mount 模式ENTRYPOINT 必须用完整路径build 期 symlink 被 bind mount 覆盖)
RUN chmod +x /var/www/html/source/stack/docker-dev-sync/source/docker/sync.sh
RUN chmod +x /var/www/html/source/stack/docker-dev-sync/source/docker/run.sh
# Start Nginx and PHP-FPM
ENTRYPOINT ["/bin/bash", "/var/www/html/source/docker/run.sh"]
ENTRYPOINT ["/bin/bash", "/var/www/html/source/stack/docker-dev-sync/source/docker/run.sh"]
CMD ["server"]

View File

@@ -0,0 +1,30 @@
server {
listen 8000 default_server;
listen [::]:8000 default_server;
root /var/www/html/public;
index index.php index.html index.htm;
server_name _;
# 上传大小不限制
client_max_body_size 8192m;
# 运行时长不限制
fastcgi_read_timeout 60000;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}

View File

@@ -1,5 +1,8 @@
#!/bin/bash
# 自动检测脚本所在目录B-route 兼容bind mount 下路径为 source/stack/<mode>/source/docker/
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# ============================================
# run.sh - docker-dev-sync entrypoint
# ============================================
@@ -14,11 +17,11 @@ echo "[run] Checking source mount..."
if [ -d "/var/www/source" ] && [ "$(ls -A /var/www/source 2>/dev/null)" ]; then
echo "[run] Source directory mounted, performing initial sync..."
/bin/bash /var/www/html/source/docker/sync.sh init
/bin/bash "$SCRIPT_DIR/sync.sh" init
echo "[run] Initial sync finished."
# Start background polling
/bin/bash /var/www/html/source/docker/sync.sh watch &
/bin/bash "$SCRIPT_DIR/sync.sh" watch &
SYNC_PID=$!
echo "[run] Background sync polling started (PID: ${SYNC_PID}, interval: ${SYNC_INTERVAL:-3}s)."
else
@@ -29,16 +32,16 @@ fi
# ---- Step 2: Configure services ----
# Copy nginx config
cp /var/www/html/source/docker/nginx.conf /etc/nginx/sites-available/default
cp "$SCRIPT_DIR/nginx.conf" /etc/nginx/sites-available/default
ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
# Copy php config files
cp /var/www/html/source/docker/zz-phprun.ini /usr/local/etc/php/conf.d
cp /var/www/html/source/docker/zz-phpfpm.conf /usr/local/etc/php-fpm.d
cp "$SCRIPT_DIR/zz-phprun.ini" /usr/local/etc/php/conf.d
cp "$SCRIPT_DIR/zz-phpfpm.conf" /usr/local/php-fpm.d
# Dev mode: override production PHP config (Opcache, error display, Xdebug)
cp /var/www/html/source/docker/zzz-dev.ini /usr/local/etc/php/conf.d
cp /var/www/html/source/docker/zzz-xdebug.ini /usr/local/etc/php/conf.d
cp "$SCRIPT_DIR/zzz-dev.ini" /usr/local/etc/php/conf.d
cp "$SCRIPT_DIR/zzz-xdebug.ini" /usr/local/etc/php/conf.d
# ---- Step 3: Set directory permissions ----
mkdir -p /var/www/html/runtime && chmod -R 777 /var/www/html/runtime

View File

@@ -0,0 +1,8 @@
[www]
; 进程数不限制
pm = dynamic
pm.max_children = 150
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 30

View File

@@ -0,0 +1,26 @@
; 内存不限制
memory_limit = -1
; 上传文件大小不限制
upload_max_filesize = -1
; 运行时长不限制
max_execution_time = 0
; POST大小不限制
post_max_size = -1
; 设置时区
date.timezone = "Asia/Shanghai"
[Zend Opcache]
opcache.enable = 1
opcache.memory_consumption=128
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=80000
opcache.revalidate_freq=3
opcache.fast_shutdown=1
opcache.enable_cli=1
opcache.jit_buffer_size=128m
opcache.jit=1205