feat: user node user for all the operations instead of root
This commit is contained in:
20
Dockerfile
20
Dockerfile
@@ -1,14 +1,18 @@
|
|||||||
FROM node:22-alpine
|
FROM node:22-alpine
|
||||||
|
|
||||||
WORKDIR /app
|
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
|
||||||
|
ENV PATH=$NPM_CONFIG_PREFIX/bin:$PATH
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV CLAUDE_CONFIG_DIR=/home/node/.claude
|
||||||
|
|
||||||
|
USER node
|
||||||
|
|
||||||
|
WORKDIR /home/node/app
|
||||||
|
|
||||||
RUN npm install -g @anthropic-ai/claude-code
|
RUN npm install -g @anthropic-ai/claude-code
|
||||||
|
|
||||||
RUN apk add --no-cache bash
|
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
|
||||||
ENV CLAUDE_CONFIG_DIR=/root/.claude
|
|
||||||
|
|
||||||
# Ensure config directory exists
|
|
||||||
RUN mkdir -p $CLAUDE_CONFIG_DIR
|
RUN mkdir -p $CLAUDE_CONFIG_DIR
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/bash", "-c", "claude; exec /bin/bash"]
|
# Since we destroy the container after exiting, claude code never gets updated.
|
||||||
|
# Updating at the start making sure its up to date.
|
||||||
|
ENTRYPOINT ["/bin/sh", "-c", "npm update -g @anthropic-ai/claude-code; claude; exec /bin/sh"]
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -1,13 +1,14 @@
|
|||||||
# isolated-claude-code
|
# isolated-claude-code
|
||||||
|
|
||||||
1. Build the docker image. `docker build -t claude-code `
|
1. Build the docker image. `docker build -t claude-code .`
|
||||||
2. Run the container `docker run --rm -it -v "$(git rev-parse --show-toplevel 2>/dev/null || pwd)":/app -v "$HOME/.claude":/root/.claude claude-code`
|
2. Run the container:
|
||||||
|
|
||||||
You can also add a shell alias:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
alias claude='docker run --rm -it \
|
docker run --rm -it \
|
||||||
-v "$(git rev-parse --show-toplevel 2>/dev/null || pwd)":/app \
|
--user "$(id -u):$(id -g)" \
|
||||||
-v "$HOME/.claude":/root/.claude \
|
-v "$(pwd)":/home/node/app \
|
||||||
claude-code'
|
-v "$HOME/.claude":/home/node/.claude \
|
||||||
|
claude-code
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can add a shell alias to faster access.
|
||||||
|
|||||||
Reference in New Issue
Block a user