mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
fix: 简化为root用户运行,彻底解决权限问题
- 移除claude用户创建,直接使用root用户运行 - 删除所有复杂的权限设置和chown操作 - 恢复简单的sed命令修改配置文件 - 移除调试权限信息输出 - 简化Dockerfile,减少构建复杂度 - 确保所有文件操作都有完整权限 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
24
Dockerfile
24
Dockerfile
@@ -13,10 +13,6 @@ RUN apk add --no-cache \
|
||||
sed \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
# 👤 创建应用用户
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S claude -u 1001 -G nodejs
|
||||
|
||||
# 📁 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
@@ -28,30 +24,22 @@ RUN npm ci --only=production && \
|
||||
npm cache clean --force
|
||||
|
||||
# 📋 复制应用代码
|
||||
COPY --chown=claude:nodejs . .
|
||||
COPY . .
|
||||
|
||||
# 🔧 复制并设置启动脚本权限
|
||||
COPY --chown=claude:nodejs docker-entrypoint.sh /usr/local/bin/
|
||||
COPY 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 /app && \
|
||||
chmod 775 /app && \
|
||||
chmod 775 /app/logs /app/data /app/temp /app/config
|
||||
# 📁 创建必要目录
|
||||
RUN mkdir -p 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 && \
|
||||
chmod 664 /app/config/config.js /app/.env 2>/dev/null || true
|
||||
|
||||
# 🔐 切换到非 root 用户
|
||||
USER claude
|
||||
fi
|
||||
|
||||
# 🌐 暴露端口
|
||||
EXPOSE 3000
|
||||
|
||||
Reference in New Issue
Block a user