Files
ulthon_admin/source/stack/full/source/docker/run.sh
augushong e5cbb48bcc fix(stack): 开发模式移除VOLUME消除runtime遮蔽,run.sh权限与su写法修复
- docker-dev/docker-dev-sync 删除 4 行 VOLUME:匿名卷会遮蔽整目录 bind mount 的宿主 runtime(已实证:宿主看不到容器日志)
- run.sh 统一四目录 777 + umask + 正确 su 写法(-s /bin/sh,www-data 为 nologin)
- serve/full/author 生产模式 VOLUME 保留作 docker run -v 兜底
2026-09-09 14:45:21 +00:00

49 lines
2.1 KiB
Bash
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.

#!/bin/bash
# 自动检测脚本所在目录(B-route 兼容:bind mount 下路径为 source/stack/<mode>/source/docker/)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# 将代码中的nginx复制到nginx配置文件中
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 "$SCRIPT_DIR/zz-phprun.ini" /usr/local/etc/php/conf.d
cp "$SCRIPT_DIR/zz-phpfpm.conf" /usr/local/php-fpm.d
# 设置目录权限,确保挂载卷后依然有效
mkdir -p /var/www/html/runtime && chmod -R 777 /var/www/html/runtime
mkdir -p /var/www/html/public/storage && chmod -R 777 /var/www/html/public/storage
mkdir -p /var/www/html/public/build && chmod -R 777 /var/www/html/public/build
mkdir -p /var/www/html/storage && chmod -R 777 /var/www/html/storage
mkdir -p /var/www/html/memoryspace && chown -R www-data:www-data /var/www/html/memoryspace
# 复制 nginx_log 分析的 log_format 配置到 nginx http 块(conf.d 自动 include)
cp "$SCRIPT_DIR/nginx-log-format.conf" /etc/nginx/conf.d/
# 创建 nginx access_log 目录(必须在 service nginx start 之前)
mkdir -p /var/www/html/runtime/nginx && chmod 777 /var/www/html/runtime/nginx
# 运行redis
# nohup redis-server --requirepass "" &
# 输出参数
echo "参数为:$@"
# TODO:增加自动批量运行并阻塞的脚本,比如:group default ,会调用auto.sh的default的部分,最终阻塞,auth.sh的default部分,可能会运行一系列的命令,比如清空缓存,踢人下线,重置密码
if [ "$1" = "server" ] || [ "$1" = "" ]; then
# 运行定时任务(以 www-data 运行;www-data 是 nologin 账户,必须 -s /bin/sh 覆盖 shell,用户名放最后)
# 注意不要写成 su -www-data(会被解析为 -w 选项导致以 root 运行)或 su - www-data(nologin 直接报错)
su -s /bin/sh -c "nohup php /var/www/html/think timer --local --quiet &" www-data
# 运行nginx
service nginx start
# 运行php-fpm
php-fpm
else
php "/var/www/html/""$@"
fi