From 544604ebffcf4bb442a6fbc4a4b93fea1420ab0d Mon Sep 17 00:00:00 2001 From: augushong Date: Wed, 22 Jul 2026 23:40:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(stack):=20=E5=85=B6=E4=BD=994=E4=B8=AA?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E5=90=8C=E6=AD=A5=20bind=20mount=20=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 与 docker-dev(commit 5797885)保持一致的修复方案: - run.sh 改为 SCRIPT_DIR 自动检测脚本所在目录 - Dockerfile ENTRYPOINT/chmod 改为完整路径 /var/www/html/source/stack//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 --- source/stack/author/Dockerfile | 5 ++-- source/stack/author/source/docker/nginx.conf | 30 +++++++++++++++++++ source/stack/author/source/docker/run.sh | 11 ++++--- .../stack/author/source/docker/zz-phpfpm.conf | 8 +++++ .../stack/author/source/docker/zz-phprun.ini | 26 ++++++++++++++++ source/stack/docker-dev-sync/Dockerfile | 7 +++-- .../docker-dev-sync/source/docker/nginx.conf | 30 +++++++++++++++++++ .../docker-dev-sync/source/docker/run.sh | 17 ++++++----- .../source/docker/zz-phpfpm.conf | 8 +++++ .../source/docker/zz-phprun.ini | 26 ++++++++++++++++ source/stack/docker-serve/Dockerfile | 5 ++-- .../docker-serve/source/docker/nginx.conf | 30 +++++++++++++++++++ .../stack/docker-serve/source/docker/run.sh | 11 ++++--- .../docker-serve/source/docker/zz-phpfpm.conf | 8 +++++ .../docker-serve/source/docker/zz-phprun.ini | 26 ++++++++++++++++ source/stack/full/Dockerfile | 5 ++-- source/stack/full/source/docker/nginx.conf | 30 +++++++++++++++++++ source/stack/full/source/docker/run.sh | 11 ++++--- .../stack/full/source/docker/zz-phpfpm.conf | 8 +++++ source/stack/full/source/docker/zz-phprun.ini | 26 ++++++++++++++++ 20 files changed, 300 insertions(+), 28 deletions(-) create mode 100644 source/stack/author/source/docker/nginx.conf create mode 100644 source/stack/author/source/docker/zz-phpfpm.conf create mode 100644 source/stack/author/source/docker/zz-phprun.ini create mode 100644 source/stack/docker-dev-sync/source/docker/nginx.conf create mode 100644 source/stack/docker-dev-sync/source/docker/zz-phpfpm.conf create mode 100644 source/stack/docker-dev-sync/source/docker/zz-phprun.ini create mode 100644 source/stack/docker-serve/source/docker/nginx.conf create mode 100644 source/stack/docker-serve/source/docker/zz-phpfpm.conf create mode 100644 source/stack/docker-serve/source/docker/zz-phprun.ini create mode 100644 source/stack/full/source/docker/nginx.conf create mode 100644 source/stack/full/source/docker/zz-phpfpm.conf create mode 100644 source/stack/full/source/docker/zz-phprun.ini diff --git a/source/stack/author/Dockerfile b/source/stack/author/Dockerfile index 3259aab..6f8554f 100644 --- a/source/stack/author/Dockerfile +++ b/source/stack/author/Dockerfile @@ -28,9 +28,10 @@ VOLUME /var/www/html/storage # 暴露 Nginx 端口 EXPOSE 8000 -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/author/source/docker/run.sh # 启动 Nginx PHP 然后阻塞 -ENTRYPOINT ["/bin/bash", "/var/www/html/source/docker/run.sh"] +ENTRYPOINT ["/bin/bash", "/var/www/html/source/stack/author/source/docker/run.sh"] CMD ["server"] diff --git a/source/stack/author/source/docker/nginx.conf b/source/stack/author/source/docker/nginx.conf new file mode 100644 index 0000000..801249e --- /dev/null +++ b/source/stack/author/source/docker/nginx.conf @@ -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; + } +} diff --git a/source/stack/author/source/docker/run.sh b/source/stack/author/source/docker/run.sh index 31c2327..c7630eb 100644 --- a/source/stack/author/source/docker/run.sh +++ b/source/stack/author/source/docker/run.sh @@ -1,12 +1,15 @@ #!/bin/bash +# 自动检测脚本所在目录(B-route 兼容:bind mount 下路径为 source/stack//source/docker/) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + # 将代码中的nginx复制到nginx配置文件中 -cp /var/www/html/source/docker/nginx.conf /etc/nginx/sites-available/default -ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default +cp "$SCRIPT_DIR/nginx.conf" /etc/nginx/sites-available/default +ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default # 将代码中的php配置文件复制到php配置文件中 -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 # 设置目录权限,确保挂载卷后依然有效 diff --git a/source/stack/author/source/docker/zz-phpfpm.conf b/source/stack/author/source/docker/zz-phpfpm.conf new file mode 100644 index 0000000..a145c68 --- /dev/null +++ b/source/stack/author/source/docker/zz-phpfpm.conf @@ -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 \ No newline at end of file diff --git a/source/stack/author/source/docker/zz-phprun.ini b/source/stack/author/source/docker/zz-phprun.ini new file mode 100644 index 0000000..a810c16 --- /dev/null +++ b/source/stack/author/source/docker/zz-phprun.ini @@ -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 \ No newline at end of file diff --git a/source/stack/docker-dev-sync/Dockerfile b/source/stack/docker-dev-sync/Dockerfile index a0c0c51..76a3afc 100644 --- a/source/stack/docker-dev-sync/Dockerfile +++ b/source/stack/docker-dev-sync/Dockerfile @@ -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"] diff --git a/source/stack/docker-dev-sync/source/docker/nginx.conf b/source/stack/docker-dev-sync/source/docker/nginx.conf new file mode 100644 index 0000000..801249e --- /dev/null +++ b/source/stack/docker-dev-sync/source/docker/nginx.conf @@ -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; + } +} diff --git a/source/stack/docker-dev-sync/source/docker/run.sh b/source/stack/docker-dev-sync/source/docker/run.sh index 4ccd32f..8b32241 100644 --- a/source/stack/docker-dev-sync/source/docker/run.sh +++ b/source/stack/docker-dev-sync/source/docker/run.sh @@ -1,5 +1,8 @@ #!/bin/bash +# 自动检测脚本所在目录(B-route 兼容:bind mount 下路径为 source/stack//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 diff --git a/source/stack/docker-dev-sync/source/docker/zz-phpfpm.conf b/source/stack/docker-dev-sync/source/docker/zz-phpfpm.conf new file mode 100644 index 0000000..a145c68 --- /dev/null +++ b/source/stack/docker-dev-sync/source/docker/zz-phpfpm.conf @@ -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 \ No newline at end of file diff --git a/source/stack/docker-dev-sync/source/docker/zz-phprun.ini b/source/stack/docker-dev-sync/source/docker/zz-phprun.ini new file mode 100644 index 0000000..a810c16 --- /dev/null +++ b/source/stack/docker-dev-sync/source/docker/zz-phprun.ini @@ -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 \ No newline at end of file diff --git a/source/stack/docker-serve/Dockerfile b/source/stack/docker-serve/Dockerfile index 39f71f0..1ccd8da 100644 --- a/source/stack/docker-serve/Dockerfile +++ b/source/stack/docker-serve/Dockerfile @@ -28,10 +28,11 @@ VOLUME /var/www/html/storage # 暴露 Nginx 端口 EXPOSE 8000 -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-serve/source/docker/run.sh # 启动 Nginx PHP 然后阻塞 -ENTRYPOINT ["/bin/bash", "/var/www/html/source/docker/run.sh"] +ENTRYPOINT ["/bin/bash", "/var/www/html/source/stack/docker-serve/source/docker/run.sh"] CMD ["server"] diff --git a/source/stack/docker-serve/source/docker/nginx.conf b/source/stack/docker-serve/source/docker/nginx.conf new file mode 100644 index 0000000..801249e --- /dev/null +++ b/source/stack/docker-serve/source/docker/nginx.conf @@ -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; + } +} diff --git a/source/stack/docker-serve/source/docker/run.sh b/source/stack/docker-serve/source/docker/run.sh index 31c2327..c7630eb 100644 --- a/source/stack/docker-serve/source/docker/run.sh +++ b/source/stack/docker-serve/source/docker/run.sh @@ -1,12 +1,15 @@ #!/bin/bash +# 自动检测脚本所在目录(B-route 兼容:bind mount 下路径为 source/stack//source/docker/) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + # 将代码中的nginx复制到nginx配置文件中 -cp /var/www/html/source/docker/nginx.conf /etc/nginx/sites-available/default -ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default +cp "$SCRIPT_DIR/nginx.conf" /etc/nginx/sites-available/default +ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default # 将代码中的php配置文件复制到php配置文件中 -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 # 设置目录权限,确保挂载卷后依然有效 diff --git a/source/stack/docker-serve/source/docker/zz-phpfpm.conf b/source/stack/docker-serve/source/docker/zz-phpfpm.conf new file mode 100644 index 0000000..a145c68 --- /dev/null +++ b/source/stack/docker-serve/source/docker/zz-phpfpm.conf @@ -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 \ No newline at end of file diff --git a/source/stack/docker-serve/source/docker/zz-phprun.ini b/source/stack/docker-serve/source/docker/zz-phprun.ini new file mode 100644 index 0000000..a810c16 --- /dev/null +++ b/source/stack/docker-serve/source/docker/zz-phprun.ini @@ -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 \ No newline at end of file diff --git a/source/stack/full/Dockerfile b/source/stack/full/Dockerfile index 92bd331..cc77380 100644 --- a/source/stack/full/Dockerfile +++ b/source/stack/full/Dockerfile @@ -75,10 +75,11 @@ VOLUME /var/www/html/storage # 暴露 Nginx 端口 EXPOSE 8000 -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/full/source/docker/run.sh # 启动 Nginx PHP 然后阻塞 -ENTRYPOINT ["/bin/bash", "/var/www/html/source/docker/run.sh"] +ENTRYPOINT ["/bin/bash", "/var/www/html/source/stack/full/source/docker/run.sh"] CMD ["server"] diff --git a/source/stack/full/source/docker/nginx.conf b/source/stack/full/source/docker/nginx.conf new file mode 100644 index 0000000..801249e --- /dev/null +++ b/source/stack/full/source/docker/nginx.conf @@ -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; + } +} diff --git a/source/stack/full/source/docker/run.sh b/source/stack/full/source/docker/run.sh index 31c2327..c7630eb 100644 --- a/source/stack/full/source/docker/run.sh +++ b/source/stack/full/source/docker/run.sh @@ -1,12 +1,15 @@ #!/bin/bash +# 自动检测脚本所在目录(B-route 兼容:bind mount 下路径为 source/stack//source/docker/) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + # 将代码中的nginx复制到nginx配置文件中 -cp /var/www/html/source/docker/nginx.conf /etc/nginx/sites-available/default -ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default +cp "$SCRIPT_DIR/nginx.conf" /etc/nginx/sites-available/default +ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default # 将代码中的php配置文件复制到php配置文件中 -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 # 设置目录权限,确保挂载卷后依然有效 diff --git a/source/stack/full/source/docker/zz-phpfpm.conf b/source/stack/full/source/docker/zz-phpfpm.conf new file mode 100644 index 0000000..a145c68 --- /dev/null +++ b/source/stack/full/source/docker/zz-phpfpm.conf @@ -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 \ No newline at end of file diff --git a/source/stack/full/source/docker/zz-phprun.ini b/source/stack/full/source/docker/zz-phprun.ini new file mode 100644 index 0000000..a810c16 --- /dev/null +++ b/source/stack/full/source/docker/zz-phprun.ini @@ -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 \ No newline at end of file