fix: 彻底修复权限问题,确保data目录可写

- 修复Dockerfile中权限设置顺序,避免递归覆盖
- 设置data目录权限为775,确保claude用户可写入init.json
- 为config目录和配置文件设置正确权限(775/664)
- 添加调试信息显示用户和目录权限状态
- 移除-R标志,精确控制每个目录的权限
- 确保setup.js能够成功创建/app/data/init.json文件

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
shaw
2025-07-19 02:20:09 +08:00
parent 0eb2561a8a
commit ea5ee199b6
2 changed files with 10 additions and 4 deletions

View File

@@ -36,9 +36,9 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# 📁 创建必要目录并设置权限
RUN mkdir -p logs data temp && \
chown -R claude:nodejs /app logs data temp && \
chmod -R 755 /app && \
chmod -R 775 logs data temp
chown -R claude:nodejs /app && \
chmod 755 /app && \
chmod 775 logs data temp config
# 🔧 预先创建配置文件避免权限问题
RUN if [ ! -f "/app/config/config.js" ] && [ -f "/app/config/config.example.js" ]; then \
@@ -47,7 +47,8 @@ RUN if [ ! -f "/app/config/config.js" ] && [ -f "/app/config/config.example.js"
if [ ! -f "/app/.env" ] && [ -f "/app/.env.example" ]; then \
cp /app/.env.example /app/.env; \
fi && \
chown claude:nodejs /app/config/config.js /app/.env 2>/dev/null || true
chown claude:nodejs /app/config/config.js /app/.env 2>/dev/null || true && \
chmod 664 /app/config/config.js /app/.env 2>/dev/null || true
# 🔐 切换到非 root 用户
USER claude