Merge pull request #53 from scarletsky/feat/support-docker

Support Docker & Docker Compose
This commit is contained in:
きむそん
2025-11-03 20:58:24 +09:00
committed by GitHub
5 changed files with 137 additions and 0 deletions

31
.dockerignore Normal file
View File

@@ -0,0 +1,31 @@
# VCS metadata
.git
.gitignore
# Local dependencies and caches
node_modules
.pnpm-store
# Build artifacts
dist
build
.turbo
.cache
# Test fixtures and docs not needed in image
e2e
mock-global-claude-dir
docs
coverage
# Editor and OS files
.DS_Store
.idea
.vscode
# Logs and environment files
*.log
npm-debug.log*
pnpm-debug.log*
.env
.env.*

30
Dockerfile Normal file
View File

@@ -0,0 +1,30 @@
# syntax=docker/dockerfile:1.7
FROM node:22-slim AS base
ENV PNPM_HOME=/usr/local/share/pnpm
ENV PATH=${PNPM_HOME}:${PATH}
RUN corepack enable pnpm && apt-get update && apt-get install -y git openssh-client && rm -rf /var/lib/apt/lists/*
FROM base AS builder
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
pnpm install --frozen-lockfile
COPY . .
RUN chmod +x scripts/docker-entrypoint.sh
RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
pnpm build && pnpm prune --prod
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production \
PORT=3400 \
PATH="/app/node_modules/.bin:${PATH}"
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/scripts/docker-entrypoint.sh ./scripts/docker-entrypoint.sh
COPY package.json pnpm-lock.yaml ./
EXPOSE 3400
ENTRYPOINT ["./scripts/docker-entrypoint.sh"]
CMD ["node", "dist/main.js"]

View File

@@ -63,6 +63,40 @@ claude-code-viewer
The server will start on port 3400 (or your specified PORT). Open `http://localhost:3400` in your browser to access the interface.
### Docker Deployment
Build the image locally:
```bash
docker build -t claude-code-viewer .
```
Run the container directly:
```bash
docker run --rm -p 3400:3400 \
-e ANTHROPIC_BASE_URL=... \
-e ANTHROPIC_API_KEY=... \
-e ANTHROPIC_AUTH_TOKEN=... \
claude-code-viewer
```
Alternatively, use the provided Compose configuration:
```bash
docker compose up --build
```
> Note: `docker-compose.yml` ships without mounting `claude_home` by default. If you need the container to reuse an existing Claude workspace, map a volume to `/root/.claude`, for example:
>
> ```yaml
> services:
> app:
> volumes:
> - /path/to/claude_home:/root/.claude
> ```
## Data Source
The application reads Claude Code conversation logs from:

20
docker-compose.yml Normal file
View File

@@ -0,0 +1,20 @@
services:
app:
build: .
environment:
NODE_ENV: production
PORT: 3400
ANTHROPIC_BASE_URL: ""
ANTHROPIC_API_KEY: ""
ANTHROPIC_AUTH_TOKEN: ""
ports:
- "3400:3400"
volumes:
# - claude_home:/root/.claude
- workspace:/root/workspace
restart: unless-stopped
init: true
volumes:
claude_home:
workspace:

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
CLAUDE_HOME="${HOME}/.claude"
# Make sure `~/.claude/projects` folder exists.
mkdir -p "$CLAUDE_HOME/projects"
# Only bootstrap when Claude home is backed by an external volume.
if ! mountpoint -q "$CLAUDE_HOME" && [ ! -f "$CLAUDE_HOME/settings.json" ]; then
cat <<EOF > "$CLAUDE_HOME/settings.json"
{
"env": {
"ANTHROPIC_BASE_URL": "${ANTHROPIC_BASE_URL:-}",
"ANTHROPIC_API_KEY": "${ANTHROPIC_API_KEY:-}",
"ANTHROPIC_AUTH_TOKEN": "${ANTHROPIC_AUTH_TOKEN:-}"
}
}
EOF
fi
exec "$@"