mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
fix: 解决Docker权限问题,预先创建配置文件
- 在Dockerfile中预先创建config.js和.env文件避免运行时权限问题 - 设置正确的目录权限(755)和文件所有者(claude:nodejs) - 简化docker-entrypoint.sh脚本,只处理文件内容修改而非创建 - 添加调试信息和错误处理 - 确保claude用户有足够权限修改配置文件 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
15
Dockerfile
15
Dockerfile
@@ -34,9 +34,20 @@ COPY --chown=claude:nodejs . .
|
||||
COPY --chown=claude:nodejs docker-entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
# 📁 创建必要目录
|
||||
# 📁 创建必要目录并设置权限
|
||||
RUN mkdir -p logs data temp && \
|
||||
chown -R claude:nodejs logs data temp
|
||||
chown -R claude:nodejs /app logs data temp && \
|
||||
chmod -R 755 /app && \
|
||||
chmod -R 775 logs data temp
|
||||
|
||||
# 🔧 预先创建配置文件避免权限问题
|
||||
RUN if [ ! -f "/app/config/config.js" ] && [ -f "/app/config/config.example.js" ]; then \
|
||||
cp /app/config/config.example.js /app/config/config.js; \
|
||||
fi && \
|
||||
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
|
||||
|
||||
# 🔐 切换到非 root 用户
|
||||
USER claude
|
||||
|
||||
Reference in New Issue
Block a user