Skip to content

Commit 326489d

Browse files
committed
Initial commit
0 parents  commit 326489d

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build and Push Image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Buildah
22+
uses: redhat-actions/buildah-build@v2
23+
with:
24+
image: ""
25+
containerfiles: |
26+
/dev/null
27+
# This just sets up buildah, we'll run our script manually
28+
29+
- name: Login to GitHub Container Registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Build Image with buildah script
37+
run: |
38+
# Run the build script
39+
./devops/build-image.sh
40+
41+
# Tag the image for GHCR
42+
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
43+
44+
# Push to GitHub Container Registry
45+
buildah push ghcr.io/$REPO_NAME/claude-code

bin/claude

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
echo podman run \
4+
-v "${HOME}/.claude:/home/claude/.claude" \
5+
-v "${HOME}/.claude.json:/home/claude/.claude.json" \
6+
-v "${PWD}:${PWD}" \
7+
-w "$PWD" \
8+
--rm \
9+
-ti \
10+
--user claude \
11+
--userns=keep-id:uid=1001,gid=1001 \
12+
claude-code:latest
13+
14+
podman run \
15+
-v "${HOME}/.claude:/home/claude/.claude" \
16+
-v "${HOME}/.claude.json:/home/claude/.claude.json" \
17+
-v "${PWD}:${PWD}" \
18+
-w "$PWD" \
19+
--rm \
20+
-ti \
21+
--user claude \
22+
--userns=keep-id:uid=1001,gid=1001 \
23+
claude-code:latest

devops/build-image.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
CONTAINER=$(buildah from docker.io/node:current-alpine)
4+
CLAUDE_VERSION=$(npm info @anthropic-ai/claude-code --json | jq .version -r)
5+
IMAGE=claude-code
6+
7+
#apk add --no-cache dash
8+
buildah run "$CONTAINER" sh <<EOT
9+
npm config set os linux
10+
apk add --no-cache zsh
11+
npm --os=linux install --omit=dev --no-audit --no-fund -g @anthropic-ai/claude-code
12+
apk cache clean
13+
rm -rf /usr/local/lib/node_modules/npm/man/
14+
find . -type f -name '*.md' -delete 2> /dev/null
15+
adduser -D claude
16+
EOT
17+
18+
buildah config \
19+
--author "Evan Carroll" \
20+
--env "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
21+
--env "SHELL=/usr/bin/zsh" \
22+
--cmd "" \
23+
--entrypoint '[ "/usr/local/bin/node", "--no-warnings", "--enable-source-maps", "/usr/local/bin/claude" ]' \
24+
"$CONTAINER"
25+
26+
buildah commit \
27+
--rm \
28+
"$CONTAINER" "$IMAGE"
29+
30+
buildah tag "$IMAGE" "$CLAUDE_VERSION"
31+
32+
echo To use the image [${IMAGE}:${CLAUDE_VERSION}] run /bin/claude

0 commit comments

Comments
 (0)