Skip to content

Commit 80665e1

Browse files
committed
Add Docker-based development environment with optimized CI
Features: - Create Dockerfile.dev with all linting tools (shellcheck, shfmt, markdownlint-cli2) - Add Makefile with convenient targets for linting and formatting - Update .pre-commit-config.yaml to run all tools via Docker - Rewrite SETUP.md for Docker-only workflow (removes local installation steps) - Add Docker-based development section to AGENTS.md - Update CI workflow (lint.yml) with matrix strategy and Docker layer caching - Use node:lts-alpine for latest Node.js LTS version - Disable Docker CLI hints and use --quiet flag for cleaner output - Update GitHub Actions to latest versions (docker/build-push-action@v6) Benefits: - Developers and AI agents only need Docker installed - All development tools run in containers - Consistent tool versions across local development and CI - Optimized CI with single image build and parallel checks - Faster builds with Docker layer caching via GitHub Actions cache
1 parent cd80977 commit 80665e1

7 files changed

Lines changed: 310 additions & 195 deletions

File tree

.github/workflows/checkshell.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Lint Code
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build-dev:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v6
11+
- uses: docker/setup-buildx-action@v3
12+
- uses: docker/build-push-action@v6
13+
with:
14+
file: Dockerfile.dev
15+
tags: node-minimal-dev:latest
16+
push: false
17+
cache-to: type=gha
18+
cache-from: type=gha
19+
20+
checks:
21+
runs-on: ubuntu-latest
22+
needs: build-dev
23+
strategy:
24+
matrix:
25+
check: [shfmt, shellcheck, markdownlint]
26+
steps:
27+
- uses: actions/checkout@v6
28+
- uses: docker/setup-buildx-action@v3
29+
- uses: docker/build-push-action@v6
30+
with:
31+
file: Dockerfile.dev
32+
tags: node-minimal-dev:latest
33+
load: true
34+
cache-from: type=gha
35+
- name: Run ${{ matrix.check }}
36+
run: |
37+
case "${{ matrix.check }}" in
38+
shfmt)
39+
docker run --rm -v "$(pwd)":/workspace -w /workspace node-minimal-dev shfmt -sr -i 2 -l -w -ci *.sh
40+
git diff --color --exit-code
41+
;;
42+
shellcheck)
43+
docker run --rm -v "$(pwd)":/workspace -w /workspace node-minimal-dev shellcheck *.sh
44+
;;
45+
markdownlint)
46+
docker run --rm -v "$(pwd)":/workspace -w /workspace node-minimal-dev markdownlint-cli2 "*.md"
47+
;;
48+
esac

.pre-commit-config.yaml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
repos:
2-
- repo: https://github.com/shellcheck-py/shellcheck-py
3-
rev: v0.10.0.1
2+
- repo: local
43
hooks:
5-
- id: shellcheck
4+
- id: shfmt-docker
5+
name: shfmt (Docker)
6+
entry: bash -c 'docker run --rm -v "$(pwd)":/workspace -w /workspace node-minimal-dev shfmt -sr -i 2 -l -w -ci *.sh'
7+
language: system
68
types: [shell]
79
files: \.(sh|bats)$
10+
pass_filenames: false
811

9-
- repo: https://github.com/scop/pre-commit-shfmt
10-
rev: v3.9.0-1
12+
- repo: local
1113
hooks:
12-
- id: shfmt
13-
args: [-sr, -i, '2', -w, -ci]
14+
- id: shellcheck-docker
15+
name: shellcheck (Docker)
16+
entry: bash -c 'docker run --rm -v "$(pwd)":/workspace -w /workspace node-minimal-dev shellcheck *.sh'
17+
language: system
1418
types: [shell]
1519
files: \.(sh|bats)$
20+
pass_filenames: false
1621

17-
- repo: https://github.com/DavidAnson/markdownlint-cli2
18-
rev: v0.15.0
22+
- repo: local
1923
hooks:
20-
- id: markdownlint-cli2
24+
- id: markdownlint-docker
25+
name: markdownlint-cli2 (Docker)
26+
entry: bash -c 'docker run --rm -v "$(pwd)":/workspace -w /workspace node-minimal-dev markdownlint-cli2 "*.md"'
27+
language: system
2128
types: [markdown]
29+
pass_filenames: false

AGENTS.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,67 @@ Checks for new Node.js versions to build:
9090
- Quick start: `pre-commit install` then hooks run automatically on commit
9191
- **Branch Protection:** main branch requires passing checks and code owner review
9292

93+
## Docker-Based Development
94+
95+
All development tools run in Docker containers via `Dockerfile.dev`. This approach requires only Docker; no local installation of shellcheck, shfmt, or Node.js needed.
96+
97+
### Getting Started
98+
99+
```bash
100+
# Build the development image
101+
make build-dev
102+
103+
# Run all linters
104+
make lint
105+
106+
# Auto-fix formatting issues
107+
make format
108+
```
109+
110+
### Makefile Targets
111+
112+
The `Makefile` provides convenient targets for code quality checks:
113+
114+
- `make lint` - Run all linters (shellcheck, shfmt, markdownlint)
115+
- `make format` - Auto-fix shell script formatting with shfmt
116+
- `make shellcheck` - Run shellcheck only
117+
- `make shfmt` - Check shell script formatting
118+
- `make shfmt-fix` - Auto-fix shell formatting
119+
- `make markdown-lint` - Check markdown files
120+
- `make pre-commit-run` - Run all hooks via Docker
121+
- `make help` - Display all available targets
122+
123+
### Pre-commit Hooks with Docker
124+
125+
Pre-commit hooks are configured to run tools inside Docker containers for consistency:
126+
127+
```bash
128+
pre-commit install # Install hooks
129+
pre-commit run --all-files # Run manually
130+
```
131+
132+
Hooks automatically execute on commit using Docker images. See [SETUP.md](./SETUP.md) for complete setup instructions.
133+
134+
### For AI Agents
135+
136+
To run development checks in an agent environment with only Docker available:
137+
138+
```bash
139+
# Build development image
140+
docker build -f Dockerfile.dev -t node-minimal-dev .
141+
142+
# Run linters via Docker directly
143+
docker run --rm -v $(pwd):/workspace -w /workspace node-minimal-dev shellcheck *.sh
144+
docker run --rm -v $(pwd):/workspace -w /workspace node-minimal-dev shfmt -sr -i 2 -l -ci *.sh
145+
```
146+
147+
Or use the Makefile for simpler commands:
148+
149+
```bash
150+
make lint
151+
make format
152+
```
153+
93154
## Testing
94155

95156
### Unit Tests

Dockerfile.dev

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Development environment with linting tools
2+
FROM node:lts-alpine
3+
4+
RUN apk add --no-cache \
5+
shellcheck \
6+
shfmt
7+
8+
RUN npm install -g markdownlint-cli2
9+
10+
WORKDIR /workspace

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.PHONY: help build-dev lint shellcheck shfmt shfmt-fix markdown-lint format pre-commit-run
2+
3+
export DOCKER_CLI_HINTS=false
4+
5+
DOCKER_IMAGE := node-minimal-dev
6+
DOCKER_RUN := docker run --rm -v "$$(pwd)":/workspace -w /workspace $(DOCKER_IMAGE)
7+
8+
help:
9+
@echo "Available targets:"
10+
@echo " build-dev Build development Docker image"
11+
@echo " lint Run all linters (shellcheck, shfmt, markdownlint)"
12+
@echo " shellcheck Run shellcheck"
13+
@echo " shfmt Check shell script formatting"
14+
@echo " shfmt-fix Auto-fix shell script formatting"
15+
@echo " markdown-lint Check markdown files"
16+
@echo " format Auto-format shell scripts (alias for shfmt-fix)"
17+
@echo " pre-commit-run Run all pre-commit hooks via Docker"
18+
19+
build-dev:
20+
docker build -f Dockerfile.dev -t $(DOCKER_IMAGE) --quiet .
21+
22+
shellcheck: build-dev
23+
$(DOCKER_RUN) shellcheck *.sh
24+
25+
shfmt: build-dev
26+
$(DOCKER_RUN) shfmt -sr -i 2 -l -ci *.sh
27+
28+
shfmt-fix: build-dev
29+
$(DOCKER_RUN) shfmt -sr -i 2 -w -ci *.sh
30+
31+
markdown-lint: build-dev
32+
$(DOCKER_RUN) markdownlint-cli2 "*.md"
33+
34+
format: shfmt-fix
35+
36+
lint: shellcheck shfmt markdown-lint
37+
38+
pre-commit-run: build-dev
39+
$(DOCKER_RUN) sh -c "shfmt -sr -i 2 -l -w -ci *.sh && shellcheck *.sh && markdownlint-cli2 '*.md'"

0 commit comments

Comments
 (0)