diff --git a/Dockerfile b/Dockerfile index 3baab38..2b43bdd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,7 @@ COPY . . # would need a docker daemon inside the build. Keep these steps in step with # Dockerfile.lint, including --network=none (see its header for why). RUN make fmt-check +RUN script/assets RUN --network=none golangci-lint config verify --config .golangci.yml RUN --network=none golangci-lint run --config .golangci.yml --build-tags browser ./... diff --git a/Dockerfile.lint b/Dockerfile.lint index 105ff08..621e692 100644 --- a/Dockerfile.lint +++ b/Dockerfile.lint @@ -31,6 +31,10 @@ FROM deps AS lint COPY . . +# static/static.go embeds the Alpine.js file this extracts from 3p/; without +# it the static package does not compile and cannot be linted. +RUN script/assets + # `run` silently ignores config keys it does not recognize, so a typo would # disable a setting without a word. `config verify` is what catches that. RUN --network=none golangci-lint config verify --config .golangci.yml diff --git a/README.md b/README.md index 2d18612..a7706e3 100644 --- a/README.md +++ b/README.md @@ -1348,7 +1348,9 @@ apply. The directory is `3p/` rather than `vendor/` because Go treats a root where `go:embed` picks it up. `script/test`, `make build` and `make dev` run it first, and the Dockerfile builds through `make test` and `make build`, so nothing downloads Alpine.js. The extracted file is not committed, and -`.dockerignore` keeps any host copy out of the build context. +`.dockerignore` keeps any host copy out of the build context. `static/static.go` +names every file it embeds, so a build that skips the extraction, such as a +bare `go build`, fails with an error naming `js/alpine.min.js`. To move to a new version: download `https://registry.npmjs.org/@alpinejs/csp/-/csp-.tgz`, check it against @@ -3379,8 +3381,9 @@ version is fixed independently of the compiler's: 1. **Lint stage** (`golangci/golangci-lint:v2.12.2`, Debian-based) — installs `make`, downloads dependencies, copies the source, and runs - `make fmt-check`, then `golangci-lint config verify` and - `golangci-lint run`, both with `--network=none`. + `make fmt-check`, then `script/assets` to extract Alpine.js from + `3p/`, then `golangci-lint config verify` and `golangci-lint run`, + both with `--network=none`. 2. **Builder stage** (`golang:1.26.1-bookworm`) — depends on the lint stage passing (it copies a file from it), runs `make test` and `make build` (both extract Alpine.js from `3p/` first), and finally diff --git a/static/static.go b/static/static.go index c3f75d1..43a0916 100644 --- a/static/static.go +++ b/static/static.go @@ -5,7 +5,10 @@ import ( "embed" ) -// Static holds the embedded CSS and JavaScript files for the web UI. +// Static holds the CSS and JavaScript files the web UI's pages load. They +// are named one by one so that a missing js/alpine.min.js, which make +// assets extracts and git does not track, fails the build instead of +// leaving the pages without Alpine.js. // -//go:embed css js +//go:embed css/tailwind.css css/style.css js/app.js js/alpine.min.js var Static embed.FS