Instructions for AI coding agents working on this project.
This is a Serverspec-based testing framework for validating Docker images. The project tests Node.js Docker images built from custom Dockerfiles by creating containers, running Serverspec tests against them, and cleaning up resources.
Tech Stack:
- Ruby 3.4+ and Ruby 4.0+
- Serverspec 2.43+
- Docker API gem 2.4+
- RSpec 3.13+
- Docker BuildKit
Current Node.js versions tested:
- Node.js 22.22.0 (Maintenance LTS)
- Node.js 24.13.0 (Active LTS)
# Install dependencies locally (no sudo required)
bundle install
# Docker BuildKit is enabled by default in Rakefile
# Verify Docker is running
docker info# Run all tests in parallel (~18 seconds)
bundle exec rake
# Run tests for a specific Node.js version
bundle exec rspec spec/22/Dockerfile_spec.rb
bundle exec rspec spec/24/Dockerfile_spec.rb
# Run with verbose output
bundle exec rake --trace.
├── 22/ # Node.js 22 Dockerfile
├── 24/ # Node.js 24 Dockerfile
├── spec/
│ ├── 22/Dockerfile_spec.rb # Tests for Node.js 22
│ ├── 24/Dockerfile_spec.rb # Tests for Node.js 24
│ ├── spec_helper.rb # Helper methods (create_image, delete_image)
│ ├── node_tests.rb # Shared Node.js version tests
│ └── npm_tests.rb # Shared npm tests
├── Rakefile # Test runner with parallel execution
├── Gemfile # Ruby dependencies
└── .github/workflows/ruby.yml # CI with Ruby 3.4 & 4.0 matrix
- Create new directory:
mkdir XX/(where XX is the version) - Copy Dockerfile from existing version and update
NODE_VERSION - Create test spec:
spec/XX/Dockerfile_spec.rb - Update Rakefile to include new task
- Test locally:
bundle exec rake - Update README.md to mention new version
- Always update the
NODE_VERSIONenvironment variable - Verify GPG keys are current from nodejs/docker-node
- Test on both amd64 and arm64 if possible
- Use Debian trixie-slim as base image
# Update specific gem
bundle update <gem-name>
# Update all gems (be careful)
bundle update
# Always remove BUNDLED WITH section from Gemfile.lock for CI compatibilityAll markdown files must pass markdownlint validation before committing.
# Check all markdown files
npx markdownlint-cli *.md
# Auto-fix issues where possible
npx markdownlint-cli --fix *.mdConfiguration: See .markdownlint.json for project rules.
Key Rules:
- Line length: 120 characters max (code blocks excluded)
- Blank lines around headings and lists
- Language specified for fenced code blocks
- No bare URLs (use markdown links)
- Use proper headings (not bold text as headings)
- Node.js Version: Correct version is installed
- npm Functionality: npm commands work correctly
- Global Package Installation: Can install global npm packages
- Package Execution: Installed packages run correctly
- Use shared test helpers in
spec/node_tests.rbandspec/npm_tests.rb - Tests run inside Docker containers via docker-api gem
- Each test spec must include proper setup/teardown:
before(:all) do
create_image(tag) # Builds Docker image
end
after(:all) do
delete_image # Cleans up containers and images
end- Tests run in PARALLEL by default (Rake multitask)
- Each test gets isolated
ENV['TARGET_HOST'] - Containers are automatically cleaned up after tests
- Images are removed only if tests pass
- Use 2 spaces for indentation
- Follow existing patterns in spec files
- Use double quotes for strings
- Keep helper methods in
spec_helper.rb
# Use shared test methods
test_node("24.13.0") # Preferred
test_npm # Preferred
# Resource types commonly used
describe command("node --version")
describe package("curl")
describe file("/usr/local/bin/node")- Use multi-line RUN with
&&for layer efficiency - Always verify GPG signatures
- Clean up apt cache:
rm -rf /var/lib/apt/lists/* - Install CA certificates for HTTPS downloads
Tests run on:
- Ruby 3.4 (current stable)
- Ruby 4.0 (latest stable)
Both versions must pass before merge.
DOCKER_BUILDKIT=1: Always enabled (set in workflow and Rakefile)TARGET_HOST: Set per test for isolation (handled automatically)
- Test all changes locally before committing
- Run full test suite:
bundle exec rake - Lint markdown files:
npx markdownlint-cli *.md - Keep Node.js versions on LTS releases
- Update README.md when changing versions
- Use version pinning in Gemfile (
~>operator) - Clean up Docker resources properly
- Use parallel test execution (Rake multitask)
- Handle errors gracefully in helper methods
- Don't stop all Docker containers (only test containers)
- Don't use
sudofor bundle install (use local path) - Don't hardcode image IDs (use @image variable)
- Don't skip the
after(:all)cleanup block - Don't add BUNDLED WITH section to Gemfile.lock
- Don't test EOL (End of Life) Node.js versions
- Don't modify .bundle/config (project-level config)
- Don't disable Docker BuildKit without good reason
<type>: <short summary>
<detailed description>
<optional breaking changes>
Co-authored-by: <AI agent or human collaborator>
fix: Bug fixesfeat: New featuresperf: Performance improvementstest: Test-only changesdocs: Documentation updateschore: Dependency updates, tooling
feat: Add Node.js 26 LTS support
- Create 26/Dockerfile with NODE_VERSION=26.x.x
- Add spec/26/Dockerfile_spec.rb with version tests
- Update Rakefile to include node26 task
- Update README.md to list version 26
Tests pass on Ruby 3.4 and 4.0.
- One change per PR: Keep PRs focused
- Test coverage: Ensure all tests pass locally and in CI
- Update docs: Update README.md if user-facing changes
- Commit history: Squash commits for cleaner history
- Co-authorship: Add co-author tags for collaborators
- Always verify GPG signatures for Node.js downloads
- Use specific Debian versions (not
latest) - Minimize installed packages
- Clean up package manager cache
- Keep gems updated for security patches
- Review CVEs for docker-api and other dependencies
- Use
bundle auditto check for vulnerabilities
- Tests create isolated containers per version
- Containers are removed after tests complete
- Only stop containers created by tests (not system-wide)
- Check that Docker daemon is running
- Verify container cleanup in after(:all) block
- Verify Node.js version exists on nodejs.org
- Check GPG key servers are accessible
- Review Docker BuildKit logs
- Remove BUNDLED WITH section from Gemfile.lock
- Let CI use its native Bundler version
- Ensure Docker BuildKit is enabled
- Verify parallel execution (multitask) is working
- Check if Docker daemon has resource constraints
# List Docker images created by tests
docker images | grep test
# Check running containers
docker ps -a
# View Docker BuildKit cache
docker buildx du
# Run with verbose Rake output
bundle exec rake --trace
# Run single test with RSpec output
bundle exec rspec spec/24/Dockerfile_spec.rb --format documentation- Serverspec Documentation: http://serverspec.org/resource_types.html
- Docker API Gem: https://github.com/swipely/docker-api
- Node.js Releases: https://nodejs.org/en/about/previous-releases
- Ruby Releases: https://www.ruby-lang.org/en/downloads/releases/
When working on this project:
- Check existing patterns in similar files
- Run tests locally before committing
- Review CI output for multi-version compatibility
- Keep changes focused and well-tested
Note: For historical information about AI contributions to this project, see AI-CONTRIBUTIONS.md.