Skip to content

Commit 44a6fe2

Browse files
committed
Dev: add claude and command for generate versions
1 parent 3249c8a commit 44a6fe2

File tree

5 files changed

+188
-0
lines changed

5 files changed

+188
-0
lines changed

.claude/commands/versions.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
description: Update Node.js version information in README.md
3+
---
4+
5+
Run the `.scripts/versions.sh` script to collect Node.js, npm, and pnpm versions from all Docker images, then update the README.md file with the collected version information.
6+
7+
Steps:
8+
1. Run `.scripts/versions.sh --no-build` to collect versions from existing images
9+
2. Parse the output (format: `version|node_version|npm_version|pnpm_version`)
10+
3. Update the NodeJS table in README.md with the actual version numbers
11+
4. Keep the same table structure with columns: NodeJS | OS | Tag | Node Version | npm Version | pnpm Version | Dockerfile
12+
5. For versions with data, show the actual versions (e.g., `NodeJS 24 (v22.16.0) | Alpine v3.22 | node24 | v22.16.0 | 11.4.2 | 10.9.0`)
13+
6. For versions without data (N/A), keep them with dash placeholders (e.g., `NodeJS 14 | Alpine v3.12 | node14 | - | - | -`)
14+
7. Show a summary of what was updated
15+
16+
Important: Only update versions 15-24 in the table, leave versions 10-14 as they are with dashes.

.claude/settings.local.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(mkdir:*)",
5+
"Bash(make:*)",
6+
"Bash(docker:*)",
7+
"Bash(chmod:*)",
8+
"Bash(.scripts/versions.sh:*)"
9+
],
10+
"deny": [],
11+
"ask": []
12+
}
13+
}

.scripts/versions.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
3+
# Script to collect Node.js and npm versions from Docker images
4+
# Usage: .scripts/versions.sh [--no-build]
5+
#
6+
# Options:
7+
# --no-build Skip building images that don't exist locally
8+
9+
set -e
10+
11+
DOCKER_IMAGE="dockette/ci"
12+
BUILD_MISSING=true
13+
14+
# Parse arguments
15+
while [[ $# -gt 0 ]]; do
16+
case $1 in
17+
--no-build)
18+
BUILD_MISSING=false
19+
shift
20+
;;
21+
*)
22+
echo "Unknown option: $1"
23+
echo "Usage: $0 [--no-build]"
24+
exit 1
25+
;;
26+
esac
27+
done
28+
29+
# Array of node versions to check
30+
NODE_VERSIONS=(15 16 17 18 19 20 21 22 23 24)
31+
32+
# Detect platform
33+
PLATFORM=$(uname -m)
34+
if [ "$PLATFORM" = "arm64" ] || [ "$PLATFORM" = "aarch64" ]; then
35+
DOCKER_PLATFORM="linux/arm64"
36+
else
37+
DOCKER_PLATFORM="linux/amd64"
38+
fi
39+
40+
echo "Collecting Node.js and npm versions..." >&2
41+
echo "Platform: ${DOCKER_PLATFORM}" >&2
42+
echo "Auto-build missing images: ${BUILD_MISSING}" >&2
43+
echo "========================================" >&2
44+
echo "" >&2
45+
46+
for version in "${NODE_VERSIONS[@]}"; do
47+
tag="node${version}"
48+
echo "Checking ${DOCKER_IMAGE}:${tag}..." >&2
49+
50+
# Check if image exists locally
51+
if ! docker image inspect "${DOCKER_IMAGE}:${tag}" &> /dev/null; then
52+
if [ "$BUILD_MISSING" = true ]; then
53+
echo " Image not found. Building..." >&2
54+
if [ -d "${tag}" ]; then
55+
docker buildx build --platform "${DOCKER_PLATFORM}" --load -t "${DOCKER_IMAGE}:${tag}" "./${tag}" >&2
56+
echo " Build complete!" >&2
57+
else
58+
echo " Directory ${tag} not found. Skipping..." >&2
59+
echo "${version}|N/A|N/A|N/A"
60+
continue
61+
fi
62+
else
63+
echo " Image not found locally. Skipping..." >&2
64+
echo " Run: make build-${tag} DOCKER_PLATFORM=${DOCKER_PLATFORM} to build this image" >&2
65+
echo "" >&2
66+
echo "${version}|N/A|N/A|N/A"
67+
continue
68+
fi
69+
fi
70+
71+
# Get Node.js version
72+
node_version=$(docker run --rm "${DOCKER_IMAGE}:${tag}" node --version 2>/dev/null || echo "N/A")
73+
# Get npm version
74+
npm_version=$(docker run --rm "${DOCKER_IMAGE}:${tag}" npm --version 2>/dev/null || echo "N/A")
75+
# Get pnpm version (if available)
76+
pnpm_version=$(docker run --rm "${DOCKER_IMAGE}:${tag}" pnpm --version 2>/dev/null || echo "N/A")
77+
78+
echo " Node.js: ${node_version}" >&2
79+
echo " npm: ${npm_version}" >&2
80+
echo " pnpm: ${pnpm_version}" >&2
81+
echo "" >&2
82+
83+
# Output to stdout
84+
echo "${version}|${node_version}|${npm_version}|${pnpm_version}"
85+
done
86+
87+
echo "========================================" >&2
88+
echo "Version collection complete!" >&2

CLAUDE.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Docker Build Platform Notes
2+
3+
## Building for Multiple Platforms
4+
5+
When building Docker images, it's important to consider the target platform architecture.
6+
7+
### Default Platform in Makefile
8+
9+
The Makefile currently defaults to `linux/amd64`:
10+
11+
```makefile
12+
DOCKER_PLATFORM?=linux/amd64
13+
```
14+
15+
### Building for ARM64 (Apple Silicon)
16+
17+
If you're on an ARM64 system (Apple Silicon Macs), you should override the platform:
18+
19+
```bash
20+
make build-node24 DOCKER_PLATFORM=linux/arm64
21+
```
22+
23+
Or export it as an environment variable:
24+
25+
```bash
26+
export DOCKER_PLATFORM=linux/arm64
27+
make build-node24
28+
```
29+
30+
### Building for AMD64 (Intel/x86_64)
31+
32+
For Intel-based systems or when building for AMD64 servers:
33+
34+
```bash
35+
make build-node24 DOCKER_PLATFORM=linux/amd64
36+
```
37+
38+
### Building for Both Platforms
39+
40+
To build multi-platform images (for pushing to Docker Hub):
41+
42+
```bash
43+
docker buildx build \
44+
--platform linux/amd64,linux/arm64 \
45+
--pull \
46+
--push \
47+
-t dockette/ci:node24 \
48+
./node24
49+
```
50+
51+
**Note**: Multi-platform builds with `--push` require pushing to a registry. For local builds, use `--load` with a single platform.
52+
53+
### Quick Local Build
54+
55+
For quick local testing, you can use `--load` with your native platform:
56+
57+
```bash
58+
# Detects your platform automatically
59+
docker buildx build --load -t dockette/ci:node24 ./node24
60+
```
61+
62+
## Platform Detection
63+
64+
To check your current platform:
65+
66+
```bash
67+
uname -m # arm64 or x86_64
68+
docker version --format '{{.Server.Arch}}' # aarch64 or x86_64
69+
```

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ build-node19: _docker-build-node19
3636
build-node20: _docker-build-node20
3737
build-node21: _docker-build-node21
3838
build-node22: _docker-build-node22
39+
build-node23: _docker-build-node23
40+
build-node24: _docker-build-node24
3941

4042
build-ansitest: _docker-build-ansitest

0 commit comments

Comments
 (0)