Skip to content

Commit 05f21d6

Browse files
committed
Update version to 2.2.0, add --public option for Docker accessibility, and enhance Docker build process for multi-architecture support. Update README and Dockerfile to reflect changes.
1 parent eb13811 commit 05f21d6

7 files changed

Lines changed: 84 additions & 37 deletions

File tree

npx/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# run-claude-artifact v2.1.0
1+
# run-claude-artifact v2.2.0
22

33
This npm package exposes the `run-claude-artifact` command for use with `npx`.
44

npx/docker/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ RUN apk add --no-cache git
66
# Set working directory
77
WORKDIR /app
88

9-
# Install the run-claude-artifact package globally
10-
RUN npm install -g run-claude-artifact@latest
9+
# Clear npm cache and install the run-claude-artifact package globally
10+
# Using --force ensures we get the latest version even if cached
11+
RUN npm cache clean --force && \
12+
npm install -g run-claude-artifact@latest --force
1113

1214
# Create entrypoint script that forwards arguments to npx
1315
RUN echo '#!/bin/sh' > /entrypoint.sh && \
14-
echo 'exec npx run-claude-artifact --no-open "$@"' >> /entrypoint.sh && \
16+
echo 'exec npx run-claude-artifact --no-open --public "$@"' >> /entrypoint.sh && \
1517
chmod +x /entrypoint.sh
1618

1719
# Set entrypoint

npx/docker/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The project includes a Docker image that can be used as an alternative to `npx r
44

55
### Building the Docker Image
66

7-
Run the build script:
7+
Run the build script for **local testing**:
88

99
```bash
1010
npx/docker/build
@@ -14,6 +14,9 @@ The script will:
1414
- Build the Docker image with both version and `latest` tags
1515
- Read the version from `npx/package.json`
1616
- Display the created tags
17+
- Build for your current platform (useful for local testing)
18+
19+
**Note:** The build script is for local testing only. When publishing, the publish script will rebuild the image anyway, so you don't need to run build first.
1720

1821
The Dockerfile installs Node.js v23.11.0 (which includes npx) and the `run-claude-artifact` npm package globally.
1922

@@ -26,11 +29,14 @@ npx/docker/publish
2629
```
2730

2831
The script will:
29-
- Check if the image exists (builds it if not found)
32+
- **Always rebuild** the image using Docker buildx (even if a local image exists)
33+
- Build for both `linux/amd64` and `linux/arm64` architectures
3034
- Verify Docker Hub login
3135
- Push both version and `latest` tags to Docker Hub
3236

33-
**Note:** Make sure to run `docker login` before publishing.
37+
**Note:** The publish script always rebuilds the image to ensure both architectures are built and pushed. Running the build script first is not necessary and won't speed up the publishing process.
38+
39+
**Prerequisites:** Make sure to run `docker login` before publishing.
3440

3541
### Using the Docker Image
3642

@@ -55,4 +61,4 @@ For the `run` subcommand, use `-p 5173:5173` to map the Vite dev server port to
5561

5662
The tool clones the template repository to a temporary directory inside the container, so git operations happen entirely within the container and don't require host filesystem access.
5763

58-
The container automatically passes `--no-open` to prevent browser opening attempts inside the container. When the server starts, you'll see a message with the URL to open in your browser.
64+
The container automatically passes `--no-open --public` flags to prevent browser opening attempts and bind to 0.0.0.0 (making it accessible from outside the container). When the server starts, you'll see a message with the URL to open in your browser.

npx/docker/build

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,29 @@ if ! docker info > /dev/null 2>&1; then
2626
exit 1
2727
fi
2828

29-
# Build the Docker image with version and latest tags
30-
echo -e "${BLUE}📦 Building Docker image...${NC}"
31-
docker build -t "${IMAGE_NAME}:${VERSION}" -t "${IMAGE_NAME}:latest" .
29+
# Check if buildx is available
30+
if ! docker buildx version > /dev/null 2>&1; then
31+
echo -e "${YELLOW}⚠️ Docker buildx not available. Building for current platform only.${NC}"
32+
echo -e "${BLUE}📦 Building Docker image...${NC}"
33+
docker build -t "${IMAGE_NAME}:${VERSION}" -t "${IMAGE_NAME}:latest" .
34+
else
35+
# Create builder instance if it doesn't exist
36+
if ! docker buildx ls | grep -q "claude-artifact-builder"; then
37+
echo -e "${BLUE}🔧 Creating buildx builder instance...${NC}"
38+
docker buildx create --name claude-artifact-builder --use
39+
else
40+
docker buildx use claude-artifact-builder
41+
fi
42+
43+
# Build for multiple architectures
44+
echo -e "${BLUE}📦 Building Docker image for amd64 and arm64...${NC}"
45+
docker buildx build \
46+
--platform linux/amd64,linux/arm64 \
47+
--tag "${IMAGE_NAME}:${VERSION}" \
48+
--tag "${IMAGE_NAME}:latest" \
49+
--load \
50+
.
51+
fi
3252

3353
if [ $? -eq 0 ]; then
3454
echo -e "${GREEN}✅ Docker image built successfully!${NC}"

npx/docker/publish

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,8 @@ if ! docker info > /dev/null 2>&1; then
2626
exit 1
2727
fi
2828

29-
# Check if image exists
30-
if ! docker images | grep -q "${IMAGE_NAME}.*${VERSION}"; then
31-
echo -e "${YELLOW}⚠️ Image ${IMAGE_NAME}:${VERSION} not found.${NC}"
32-
echo -e "${BLUE}Building image first...${NC}"
33-
echo ""
34-
"$(dirname "$0")/build"
35-
if [ $? -ne 0 ]; then
36-
exit 1
37-
fi
38-
echo ""
39-
fi
40-
41-
# Check if user is logged in to Docker Hub
29+
# Check if Docker Hub credentials exist in config
30+
# Docker Hub can be stored as "https://index.docker.io/v1/" or "docker.io"
4231
DOCKER_CONFIG="${HOME}/.docker/config.json"
4332

4433
if [ ! -f "$DOCKER_CONFIG" ]; then
@@ -47,8 +36,6 @@ if [ ! -f "$DOCKER_CONFIG" ]; then
4736
exit 1
4837
fi
4938

50-
# Check if Docker Hub credentials exist in config
51-
# Docker Hub can be stored as "https://index.docker.io/v1/" or "docker.io"
5239
if ! grep -qE "(https://index\.docker\.io/v1/|docker\.io)" "$DOCKER_CONFIG" 2>/dev/null; then
5340
echo -e "${YELLOW}⚠️ Not logged in to Docker Hub. Please login first:${NC}"
5441
echo -e " docker login"
@@ -60,18 +47,40 @@ echo -e "${BLUE}✓ Docker Hub login detected${NC}"
6047
read -p "Make sure you are logged in as claudiombsilva and press Enter to continue: "
6148
echo ""
6249

63-
# Push the image
64-
echo -e "${BLUE}📤 Pushing Docker image to Docker Hub...${NC}"
65-
docker push "${IMAGE_NAME}:${VERSION}"
66-
docker push "${IMAGE_NAME}:latest"
50+
# Check if buildx is available (required for multi-architecture builds)
51+
if ! docker buildx version > /dev/null 2>&1; then
52+
echo -e "${YELLOW}⚠️ Docker buildx not available. Cannot build multi-architecture images.${NC}"
53+
echo -e "${YELLOW} Please install Docker buildx or use Docker Desktop.${NC}"
54+
exit 1
55+
fi
56+
57+
# Set up buildx builder for multi-architecture builds
58+
echo -e "${BLUE}🔧 Setting up buildx builder...${NC}"
59+
if ! docker buildx ls | grep -q "claude-artifact-builder"; then
60+
docker buildx create --name claude-artifact-builder --use
61+
else
62+
docker buildx use claude-artifact-builder
63+
fi
64+
65+
# Build and push multi-architecture images
66+
# Note: We always rebuild here to ensure both architectures are built and pushed
67+
echo -e "${BLUE}📦 Building and pushing Docker images for amd64 and arm64...${NC}"
68+
docker buildx build \
69+
--platform linux/amd64,linux/arm64 \
70+
--tag "${IMAGE_NAME}:${VERSION}" \
71+
--tag "${IMAGE_NAME}:latest" \
72+
--push \
73+
.
6774

6875
if [ $? -eq 0 ]; then
69-
echo -e "${GREEN}✅ Successfully published to Docker Hub!${NC}"
76+
echo ""
77+
echo -e "${GREEN}✅ Successfully published multi-architecture images to Docker Hub!${NC}"
78+
echo -e "${GREEN} Platforms: linux/amd64, linux/arm64${NC}"
7079
echo ""
7180
echo -e "${BLUE}Usage:${NC}"
72-
echo -e " docker run --rm -v \$(pwd):/w -w /w ${IMAGE_NAME} <artifact-file.tsx>"
81+
echo -e " docker run --rm -p 5173:5173 -v \$(pwd):/w -w /w ${IMAGE_NAME} <artifact-file.tsx>"
7382
else
74-
echo -e "${YELLOW}Failed to push to Docker Hub.${NC}"
83+
echo -e "${YELLOW}Build and push failed.${NC}"
7584
exit 1
7685
fi
7786

npx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "run-claude-artifact",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "Run Claude AI Artifacts locally - quick preview, or create projects, build, deploy, and push to a Git repository.",
55
"bin": {
66
"run-claude-artifact": "./run-claude-artifact.js"

npx/run-claude-artifact.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ async function parseArgs() {
7070
projectDir: null, // For create subcommand
7171
remote: null, // For create subcommand
7272
push: false, // For create subcommand
73-
noOpen: false // Don't open browser automatically
73+
noOpen: false, // Don't open browser automatically
74+
public: false // Bind to 0.0.0.0 instead of localhost (useful for Docker)
7475
};
7576

7677
// Handle help request
@@ -107,6 +108,7 @@ Options by Subcommand:
107108
Global Options:
108109
-h, --help Show this help message
109110
--no-open Don't open browser automatically (useful for Docker/CI)
111+
--public Bind to 0.0.0.0 instead of localhost (useful for Docker)
110112
111113
Examples:
112114
# Run Artifact (Default)
@@ -216,6 +218,8 @@ Notes:
216218
options.push = true;
217219
} else if (arg === '--no-open') {
218220
options.noOpen = true;
221+
} else if (arg === '--public') {
222+
options.public = true;
219223
} else {
220224
console.error(`❌ Unknown option: ${arg}`);
221225
process.exit(1);
@@ -469,6 +473,9 @@ async function main() {
469473
if (!options.noOpen) {
470474
viteArgs.push('--open');
471475
}
476+
if (options.public) {
477+
viteArgs.push('--host');
478+
}
472479
const runProcess = spawn('node_modules/.bin/vite', viteArgs, {
473480
cwd: repoDir,
474481
stdio: 'inherit'
@@ -480,7 +487,7 @@ async function main() {
480487
if (options.noOpen) {
481488
console.log(`🌐 Open your browser at: http://localhost:5173/`);
482489
}
483-
}, 5000);
490+
}, 2500);
484491

485492
let signalHandled = false;
486493
const handleRunSignal = (signal) => {
@@ -516,6 +523,9 @@ async function main() {
516523
if (!options.noOpen) {
517524
viteArgs.push('--open');
518525
}
526+
if (options.public) {
527+
viteArgs.push('--host');
528+
}
519529
const runProcess = spawn('node_modules/.bin/vite', viteArgs, {
520530
cwd: repoDir,
521531
stdio: 'inherit'
@@ -527,7 +537,7 @@ async function main() {
527537
if (options.noOpen) {
528538
console.log(`🌐 Open your browser at: http://localhost:5173/`);
529539
}
530-
}, 5000);
540+
}, 2500);
531541

532542
let signalHandled = false;
533543
const handleRunSignal = (signal) => {

0 commit comments

Comments
 (0)