Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions claude-code/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM debian:bookworm-slim

ARG CLAUDE_CODE_VERSION=2.1.105

LABEL version="${CLAUDE_CODE_VERSION}"

# Common dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
git \
jq \
unzip \
python3 \
awscli \
gpg \
openssh-client \
bash \
less \
&& rm -rf /var/lib/apt/lists/*

# yq (latest)
RUN curl -fsSL "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$(dpkg --print-architecture)" \
-o /usr/local/bin/yq \
&& chmod +x /usr/local/bin/yq

# GitHub CLI
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
-o /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
> /etc/apt/sources.list.d/github-cli.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends gh \
&& rm -rf /var/lib/apt/lists/*

# Non-root user
RUN useradd -m -s /bin/bash claude
USER claude
ENV HOME=/home/claude
ENV PATH="/home/claude/.local/bin:${PATH}"
WORKDIR /home/claude

# Claude Code CLI (Native Install)
RUN curl -fsSL https://claude.ai/install.sh | bash -s "${CLAUDE_CODE_VERSION}"
1 change: 1 addition & 0 deletions claude-code/Dockerfile.arm64
29 changes: 29 additions & 0 deletions claude-code/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARCH:=$(shell uname -m)
PLATFORM:=$(shell case "$(ARCH)" in \
("arm64"|"aarch64") echo "arm64" ;; \
("x86_64") echo "amd64" ;; \
(*) echo $(ARCH) ;; \
esac)

.PHONY: build
build:
@docker buildx build -t chatwork/`basename $$PWD`:latest --platform linux/${PLATFORM} -f Dockerfile --load .; \
version=$$(docker inspect -f {{.Config.Labels.version}} chatwork/`basename $$PWD`:latest); \
if [ -n "$$version" ]; then \
docker tag chatwork/`basename $$PWD`:latest chatwork/`basename $$PWD`:$$version; \
fi

.PHONY: test
test: build
docker-compose -f docker-compose.test.yml up --no-start sut
docker cp $(shell pwd)/goss `basename $$PWD`:/goss
docker-compose -f docker-compose.test.yml up --no-recreate --exit-code-from sut sut

.PHONY: push
push:
@version=$$(docker inspect -f {{.Config.Labels.version}} chatwork/`basename $$PWD`:latest); \
if docker inspect --format='{{index .RepoDigests 0}}' chatwork/$$(basename $$PWD):$$version >/dev/null 2>&1; then \
echo "no changes"; \
else \
docker buildx build -t chatwork/`basename $$PWD`:$$version -t chatwork/`basename $$PWD`:latest --platform linux/amd64,linux/arm64 -f Dockerfile --push .; \
fi
49 changes: 49 additions & 0 deletions claude-code/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# claude-code

A base Docker image for running [Claude Code](https://claude.ai/code) in containers. Provides the Claude Code CLI and common dependencies pre-installed.

This image is designed to be used as a base (`FROM chatwork/claude-code`) by teams building their own plugin marketplace runner images, or directly in Kubernetes CronJobs.

## Usage

### As a base image

```dockerfile
FROM chatwork/claude-code:latest

# Copy your marketplace plugins
COPY . /marketplace
RUN claude plugin marketplace add /marketplace
```

### In a Kubernetes CronJob

```yaml
containers:
- name: task
image: chatwork/claude-code:latest
command: ["/bin/bash", "-lc"]
args:
- |
set -euo pipefail
claude --print "Generate weekly report"
```

### Standalone

```
$ docker run --rm chatwork/claude-code claude --version
```

## Included

| Category | Tools |
|---|---|
| Core | Claude Code CLI, curl, ca-certificates, git, bash, less |
| Data processing | jq, yq, unzip |
| Cloud / CI | awscli, gh (GitHub CLI), python3 |
| Security | gpg, openssh-client |

## Version management

Claude Code CLI version is pinned and automatically updated via [variant mod](https://github.com/variantdev/mod). See `variant.mod` and `variant.lock` for details.
18 changes: 18 additions & 0 deletions claude-code/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'
services:
claude-code:
build:
context: .
image: chatwork/claude-code
sut:
image: chatwork/dgoss:latest
environment:
GOSS_FILES_PATH: /goss
GOSS_FILES_STRATEGY: cp
entrypoint: ""
command: /usr/local/bin/dgoss run --entrypoint '' chatwork/claude-code tail -f /dev/null
container_name: claude-code
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- claude-code
20 changes: 20 additions & 0 deletions claude-code/goss/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
file:
/home/claude/.local/bin/claude:
exists: true
command:
claude --version:
exit-status: 0
stdout:
- 2.1.105
git --version:
exit-status: 0
jq --version:
exit-status: 0
python3 --version:
exit-status: 0
yq --version:
exit-status: 0
gh --version:
exit-status: 0
gpg --version:
exit-status: 0
3 changes: 3 additions & 0 deletions claude-code/hooks/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

make test
7 changes: 7 additions & 0 deletions claude-code/variant.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencies:
claude_code:
version: 2.1.105
previousVersion: 2.1.100
versions:
- 2.1.100
- 2.1.105
18 changes: 18 additions & 0 deletions claude-code/variant.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
provisioners:
textReplace:
Dockerfile:
from: "ARG CLAUDE_CODE_VERSION={{ .claude_code.previousVersion }}"
to: "ARG CLAUDE_CODE_VERSION={{ .claude_code.version }}"
goss/goss.yaml:
from: "- {{ .claude_code.previousVersion }}"
to: "- {{ .claude_code.version }}"

dependencies:
claude_code:
releasesFrom:
exec:
command: bash
args:
- -c
- "curl -s https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/latest"
version: "> 2.0"
Loading