Skip to content

Commit 99b9e35

Browse files
committed
build: make Hugo validation reproducible
1 parent b52b003 commit 99b9e35

8 files changed

Lines changed: 72 additions & 16 deletions

File tree

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git
2+
.github
3+
.idea
4+
.superpowers
5+
docs
6+
node_modules
7+
public
8+
resources
9+
themes/docsy/node_modules

CLAUDE.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,20 @@ hugo --gc
5151
HUGO_ENV="production" hugo --gc
5252
```
5353

54+
The Makefile and npm scripts automatically use the pinned official Hugo
55+
container when `hugo` is not installed locally.
56+
5457
### Docker (Alternative)
5558

5659
```bash
57-
# Run using Docker Compose
58-
docker-compose up
59-
60-
# Or build and run manually
61-
docker build -t capa-docs .
62-
docker run -p 1313:1313 -v $(pwd):/src capa-docs server
60+
# Build the pinned official Hugo image
61+
docker build --build-arg HUGO_VERSION=0.145.0 -t capa-docs .
62+
63+
# Serve the local checkout (install npm dependencies first)
64+
npm ci
65+
npm --prefix themes/docsy install
66+
docker run --rm -p 1313:1313 -v "$(pwd):/project" capa-docs \
67+
server -D --bind 0.0.0.0
6368
```
6469

6570
## Architecture

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
FROM klakegg/hugo:ext-alpine
1+
ARG HUGO_VERSION=0.145.0
2+
FROM ghcr.io/gohugoio/hugo:v${HUGO_VERSION}
23

3-
RUN apk add git
4+
WORKDIR /project
5+
EXPOSE 1313

Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Capa.io Makefile
22
# Simplified build commands for Hugo documentation site
33

4-
.PHONY: dev build clean deploy help submodule
4+
.PHONY: dev build check clean deploy help submodule
55

66
# Default target
77
.DEFAULT_GOAL := help
@@ -12,15 +12,19 @@ submodule:
1212

1313
# Development server with drafts
1414
dev:
15-
hugo server -D
15+
./scripts/hugo.sh server -D
1616

1717
# Development server binding to all interfaces
1818
dev-all:
19-
hugo server -D --bind 0.0.0.0
19+
./scripts/hugo.sh server -D --bind 0.0.0.0
2020

2121
# Production build
2222
build:
23-
HUGO_ENV="production" hugo --gc --minify
23+
HUGO_ENV="production" ./scripts/hugo.sh --gc --minify
24+
25+
# Validate all pages without changing generated site files
26+
check:
27+
HUGO_ENV="production" HUGO_READ_ONLY=1 ./scripts/hugo.sh --gc --minify --renderToMemory --noBuildLock
2428

2529
# Clean build artifacts
2630
clean:
@@ -49,6 +53,7 @@ help:
4953
@echo " make dev - Run development server with drafts"
5054
@echo " make dev-all - Run dev server binding to all interfaces"
5155
@echo " make build - Build production site (outputs to docs/)"
56+
@echo " make check - Validate the production site without writing output"
5257
@echo " make clean - Remove build artifacts"
5358
@echo " make deploy - Build and deploy to GitHub Pages"
5459
@echo " make link-check - Check for broken links"

docs/maintenance/2026-06-27-capa-io-triage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
- Migrated deprecated Docsy settings, removed the fake Universal Analytics ID, and removed a duplicate blog menu declaration.
1717
- Scoped gitleaks away from the pinned Docsy submodule, whose upstream search documentation contains example keys.
1818
- Updated checkout, Node setup, Hugo, and Pages actions to their current Node 24-based major versions; the build runtime now uses Node 22 to satisfy Docsy's engine requirement.
19+
- Replaced the unmaintained Hugo-on-Alpine image with the version-pinned official Hugo image and documented the working container mount path.
20+
- Added a local Hugo wrapper so validation falls back to a read-only container when Hugo is not installed.
1921

2022
## Validation
2123

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
"scripts": {
77
"dev": "make dev",
88
"build": "make build",
9-
"lint": "make build",
10-
"test": "make build"
9+
"lint": "make check",
10+
"test": "make check"
1111
},
1212
"repository": {
1313
"type": "git",
1414
"url": "git+https://github.com/capa-cloud/capa.io.git"
1515
},
1616
"author": "",
17-
"license": "ISC",
17+
"license": "Apache-2.0",
1818
"bugs": {
1919
"url": "https://github.com/capa-cloud/capa.io/issues"
2020
},

scripts/hugo.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env sh
2+
set -eu
3+
4+
if command -v hugo >/dev/null 2>&1; then
5+
exec hugo "$@"
6+
fi
7+
8+
if ! command -v docker >/dev/null 2>&1; then
9+
echo "Hugo 0.145.0 or Docker is required." >&2
10+
exit 127
11+
fi
12+
13+
project_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
14+
hugo_image=${HUGO_IMAGE:-ghcr.io/gohugoio/hugo:v0.145.0}
15+
16+
if [ "${HUGO_READ_ONLY:-0}" = "1" ]; then
17+
exec docker run --rm \
18+
--user "$(id -u):$(id -g)" \
19+
--env HOME=/tmp \
20+
--env HUGO_CACHEDIR=/tmp/hugo-cache \
21+
--env HUGO_ENV \
22+
--volume "$project_dir:/project:ro" \
23+
--tmpfs "/project/resources:uid=$(id -u),gid=$(id -g)" \
24+
"$hugo_image" "$@"
25+
fi
26+
27+
exec docker run --rm \
28+
--user "$(id -u):$(id -g)" \
29+
--env HOME=/tmp \
30+
--env HUGO_CACHEDIR=/tmp/hugo-cache \
31+
--env HUGO_ENV \
32+
--volume "$project_dir:/project" \
33+
"$hugo_image" "$@"

0 commit comments

Comments
 (0)