Skip to content

Commit 3e2d14c

Browse files
committed
feat(setup): add Node.js and npm installation script
- Introduced a new script for installing Node.js and npm, enhancing the development environment. - Updated the setup configuration to include the new installation step, allowing for easy tools management. - Expanded documentation to detail the setup process and installation verification steps.
1 parent 45258da commit 3e2d14c

File tree

4 files changed

+135
-6
lines changed

4 files changed

+135
-6
lines changed

.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"Bash(docker inspect:*)",
1111
"WebFetch(domain:github.com)",
1212
"Bash(mv:*)",
13-
"WebFetch(domain:learn.microsoft.com)"
13+
"WebFetch(domain:learn.microsoft.com)",
14+
"Bash(find:*)"
1415
],
1516
"deny": []
1617
}

CLAUDE.md

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ This repository contains Docker images for GitHub Actions self-hosted runners wi
1414
- **Multi-Architecture Support**: Supports both AMD64 and ARM64 architectures
1515
- **CI/CD**: Uses GitHub Actions for automated building and releasing
1616

17+
### Setup System Details
18+
19+
The setup system reads `src/setup.yaml` and executes installation steps sequentially. Each step can either:
20+
- Execute a script file from `src/scripts/` directory
21+
- Run inline commands directly
22+
23+
The orchestrator (`setup.sh`) provides:
24+
- Colored logging with timestamps
25+
- Step execution tracking
26+
- Error handling with proper exit codes
27+
- Support for both `script` and `command` step types
28+
1729
## Key Commands
1830

1931
### Building the Docker Image
@@ -24,25 +36,65 @@ docker build -t github-actions-runner -f src/Dockerfile src/
2436

2537
# Build with specific platform
2638
docker buildx build --platform linux/amd64 -t github-actions-runner -f src/Dockerfile src/
39+
40+
# Build multi-platform image
41+
docker buildx build --platform linux/amd64,linux/arm64 -t github-actions-runner -f src/Dockerfile src/
42+
43+
# Build and load into local Docker (single platform only)
44+
docker buildx build --platform linux/amd64 --load -t github-actions-runner -f src/Dockerfile src/
45+
```
46+
47+
### Testing the Image Locally
48+
49+
```bash
50+
# Run the built image
51+
docker run --rm -it github-actions-runner bash
52+
53+
# Test specific tools
54+
docker run --rm github-actions-runner python3 --version
55+
docker run --rm github-actions-runner pwsh --version
56+
docker run --rm github-actions-runner az --version
2757
```
2858

2959
### Adding New Tools
3060

3161
To add a new tool to the image:
32-
1. Create an installation script in `src/scripts/` (e.g., `install-newtool.sh`)
33-
2. Add a step to `src/setup.yaml`:
62+
63+
1. **For complex installations**, create a script in `src/scripts/`:
64+
```bash
65+
# src/scripts/install-newtool.sh
66+
#!/bin/bash
67+
set -euo pipefail
68+
69+
# Architecture detection if needed
70+
ARCH=$(uname -m)
71+
case ${ARCH} in
72+
x86_64) ARCH_SUFFIX="amd64" ;;
73+
aarch64) ARCH_SUFFIX="arm64" ;;
74+
esac
75+
76+
# Installation logic here
77+
```
78+
79+
2. Add the step to `src/setup.yaml`:
3480
```yaml
3581
- name: "Install New Tool"
3682
script: "scripts/install-newtool.sh"
3783
description: "Description of what this installs"
3884
```
39-
OR use inline commands:
85+
86+
3. **For simple installations**, use inline commands:
4087
```yaml
4188
- name: "Install New Tool"
42-
command: "apt-get install -y newtool"
89+
command: "apt-get update && apt-get install -y newtool"
4390
description: "Description of what this installs"
4491
```
4592
93+
4. Make the script executable:
94+
```bash
95+
chmod +x src/scripts/install-newtool.sh
96+
```
97+
4698
### GitHub Actions Workflow
4799

48100
The repository uses GitVersion for semantic versioning. The pipeline is triggered on:
@@ -78,4 +130,32 @@ Images are published to:
78130
- Docker Hub: `emberstack/github-actions-runner`
79131
- GitHub Container Registry: `ghcr.io/emberstack/github-actions-runner`
80132

81-
Both registries receive multi-architecture manifests supporting AMD64 and ARM64.
133+
Both registries receive multi-architecture manifests supporting AMD64 and ARM64.
134+
135+
## Development Workflow
136+
137+
### Making Changes
138+
139+
1. **Modify installation scripts**: Edit files in `src/scripts/` for tool-specific changes
140+
2. **Update setup configuration**: Modify `src/setup.yaml` to add/remove/reorder steps
141+
3. **Test locally**: Build and run the image to verify changes
142+
4. **Commit with semantic versioning**: Use commit messages like:
143+
- `feat: add new tool` (minor version bump)
144+
- `fix: correct installation issue` (patch version bump)
145+
- `feat!: breaking change` or `+semver:major` (major version bump)
146+
147+
### CI/CD Pipeline Details
148+
149+
The pipeline (`pipeline.yaml`) consists of:
150+
1. **Discovery**: Determines version and whether to build/release
151+
2. **Build**: Parallel builds for each architecture
152+
3. **Manifest**: Creates multi-arch manifests
153+
4. **Release**: Creates GitHub releases (main branch only)
154+
155+
### Debugging Installation Issues
156+
157+
When debugging tool installations:
158+
1. Check the colored output from `setup.sh` for the specific failing step
159+
2. Run the Docker build with `--progress=plain` for detailed output
160+
3. Test scripts individually inside a running container
161+
4. Verify architecture-specific logic for ARM64 vs AMD64

src/scripts/install-nodejs.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# Install Node.js and npm
4+
# Uses NodeSource official setup script
5+
6+
# Detect architecture
7+
ARCH=$(uname -m)
8+
9+
echo "Installing Node.js and npm..."
10+
11+
# Install prerequisites
12+
apt-get update
13+
apt-get install -y --no-install-recommends \
14+
ca-certificates \
15+
curl
16+
17+
# Use NodeSource's official setup script for Node.js 20.x
18+
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
19+
20+
# Install Node.js (includes npm)
21+
apt-get install -y nodejs
22+
23+
# Verify Node.js installation
24+
echo "Verifying Node.js installation..."
25+
if ! command -v node &> /dev/null; then
26+
echo "ERROR: node command not found after installation"
27+
exit 1
28+
fi
29+
echo "Node.js version:"
30+
node --version
31+
32+
# Verify npm installation
33+
echo "Verifying npm installation..."
34+
if ! command -v npm &> /dev/null; then
35+
echo "ERROR: npm command not found after installation"
36+
exit 1
37+
fi
38+
echo "npm version:"
39+
npm --version
40+
41+
# Display architecture info
42+
echo "Installed on architecture: $ARCH"
43+
44+
echo "Node.js and npm installation completed successfully!"

src/setup.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ setup:
1111
script: "scripts/install-powershell.sh"
1212
description: "Installs PowerShell Core"
1313

14+
- name: "Install Node.js and npm"
15+
script: "scripts/install-nodejs.sh"
16+
description: "Installs Node.js and npm package manager"
17+
1418
- name: "Install Azure CLI"
1519
script: "scripts/install-azure-cli.sh"
1620
description: "Installs Azure CLI"

0 commit comments

Comments
 (0)