Skip to content

Commit 3eb9573

Browse files
wlgns5376claude
andcommitted
fix: Claude CLI를 비root 사용자로 설치하여 업데이트 가능하도록 수정
- npm 글로벌 디렉토리를 사용자 홈 디렉토리로 변경 (/home/appuser/.npm-global) - PATH 및 NPM_CONFIG_PREFIX 환경변수 추가 - Claude CLI 설치를 USER appuser 전환 후로 이동 - appuser가 직접 npm update -g 명령으로 Claude CLI 업데이트 가능 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f85737b commit 3eb9573

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ RUN ARCH=$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/') && \
5252
chmod +x /usr/local/bin/gh && \
5353
rm -rf /tmp/gh*
5454

55-
# Install Claude CLI
56-
# Install the official Claude CLI from npm
57-
RUN npm install -g @anthropic-ai/claude-code || \
58-
echo "Warning: Claude CLI installation failed. Please install manually or ensure API access is configured."
59-
6055
# Create app user and group
6156
RUN addgroup -g 1001 -S appgroup && \
6257
adduser -S appuser -u 1001 -G appgroup && \
@@ -90,6 +85,19 @@ RUN mkdir -p /workspace && \
9085
# Switch to non-root user
9186
USER appuser
9287

88+
# Configure npm global directory for non-root user
89+
RUN mkdir -p /home/appuser/.npm-global && \
90+
npm config set prefix '/home/appuser/.npm-global'
91+
92+
# Set npm global path in environment
93+
ENV PATH="/home/appuser/.npm-global/bin:${PATH}"
94+
ENV NPM_CONFIG_PREFIX="/home/appuser/.npm-global"
95+
96+
# Install Claude CLI
97+
# Install the official Claude CLI from npm (now can be updated without root)
98+
RUN npm install -g @anthropic-ai/claude-code || \
99+
echo "Warning: Claude CLI installation failed. Please install manually or ensure API access is configured."
100+
93101
# Set environment variables
94102
ENV NODE_ENV=production
95103
ENV WORKSPACE_DIR=/workspace

Dockerfile.all-languages

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ RUN ARCH=$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/') && \
6060
chmod +x /usr/local/bin/gh && \
6161
rm -rf /tmp/gh*
6262

63-
# Install Claude CLI
64-
# Install the official Claude CLI from npm
65-
RUN npm install -g @anthropic-ai/claude-code || \
66-
echo "Warning: Claude CLI installation failed. Please install manually or ensure API access is configured."
67-
6863
# Create app user and group
6964
RUN addgroup -g 1001 -S appgroup && \
7065
adduser -S appuser -u 1001 -G appgroup && \
@@ -98,6 +93,19 @@ RUN mkdir -p /workspace && \
9893
# Switch to non-root user
9994
USER appuser
10095

96+
# Configure npm global directory for non-root user
97+
RUN mkdir -p /home/appuser/.npm-global && \
98+
npm config set prefix '/home/appuser/.npm-global'
99+
100+
# Set npm global path in environment
101+
ENV PATH="/home/appuser/.npm-global/bin:${PATH}"
102+
ENV NPM_CONFIG_PREFIX="/home/appuser/.npm-global"
103+
104+
# Install Claude CLI
105+
# Install the official Claude CLI from npm (now can be updated without root)
106+
RUN npm install -g @anthropic-ai/claude-code || \
107+
echo "Warning: Claude CLI installation failed. Please install manually or ensure API access is configured."
108+
101109
# Set environment variables
102110
ENV NODE_ENV=production
103111
ENV WORKSPACE_DIR=/workspace

0 commit comments

Comments
 (0)