Skip to content

Fail the Docker image build when Node lacks full ICU - #890

Merged
richshaw merged 2 commits into
mainfrom
claude/issue-622-dockerfile-icu
Nov 16, 2026
Merged

richshaw merged 2 commits into
mainfrom
claude/issue-622-dockerfile-icu

Conversation

@richshaw

@richshaw richshaw commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Part of #622: the image check. The formatting itself is in the localization stack.

The stack

Stands alone, beside the localization stack (#619): based on main, review against main. The formatting PRs in the stack (slot dates and times, then the other formatters) don't depend on it, and it doesn't depend on them.

The problem

Intl formats dates and numbers only in the languages whose ICU data Node carries. A Node with English-only ICU (a small-ICU build, or one linked against a system ICU that ships only English) doesn't throw when asked for Swedish: it quietly formats in English. Once the stack formats slot dates per language, an image built on such a Node would show Swedish signups English dates, with nothing in the logs. CI can't catch it, because CI never runs the image's Node (see Tests).

The fix

  • Dockerfile: one RUN node -e step at the top of the runner stage, with a comment saying why. It fails the build unless Intl.DateTimeFormat('sv').resolvedOptions().locale is 'sv', and prints what it resolved to:

    This Node has no full ICU: Intl resolved sv to en-US, so dates would print in English for every language. Use a Node built with full ICU, as the official node images are.
    

    It sits in runner because that's the image the app, the worker and the migrate step run from (docker-compose.prod.yml builds all three from the default target). Every stage is FROM base today, but if someone points runner at a different image, the check follows the Node that actually runs.

  • CHANGELOG: one line under Changed, since someone building on a different base image could now see a new build failure. The stock node:22-alpine base is expected to pass (Node has built with full ICU by default since v13).

Nothing else from #622 is here: formatSlotDate, formatSlotTime and the other formatters are the stack's PRs. The issue's note that "CI's Node isn't the image's, so CI can't check this" still holds on today's main.

Tests

The image build itself wasn't run. This container has no Docker daemon, and CI doesn't build the image either: .github/workflows/ci.yml (the only workflow) runs lint, typecheck, knip, unit, db and e2e tests on actions/setup-node Node 22 on Ubuntu, and nothing in it runs docker build or uses the Dockerfile. So I ran the exact command instead, taken from the Dockerfile line (RUN stripped) and run through /bin/sh -c, as a shell-form RUN is:

Node Result
This container's Node 22.23.4 (ICU 78.3, official full-ICU build), as is exit 0, no output
Same, NODE_ICU_DATA pointed at an empty folder exit 0: this doesn't remove anything. A full-ICU Node has its data linked into the binary, and ICU falls back to that when the folder has nothing
Same, NODE_ICU_DATA pointed at a folder whose icudt78l/res_index.res lists only en and en_US as installed (built with Ubuntu's genrb from res_index:table(nofallback) { InstalledLocales { en {""} en_US {""} } }), which is what an English-only ICU looks like to Intl exit 1, with the message above (resolved sv to en-US)

Under that English-only data, toLocaleDateString('sv', { weekday: 'short', day: 'numeric', month: 'short', timeZone: 'UTC' }) on 2 May 2026 gives Sat, May 2 and Intl.NumberFormat('sv').format(1234.5) gives 1,234.5, against lör 2 maj and 1 234,5 with full ICU: the silent fallback the check exists to catch.

I also tried a genuinely small-ICU Node (the official Node 12 binaries were built that way), but this session isn't allowed to run a downloaded binary, so that wasn't run.

pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test: pass (2193 tests). Nothing else applies: no code, services or pages changed.

Before merging

Since nothing here could build the image, run the check against the real base once. The quick version takes seconds. After Docker's pull progress the first time, it should print only exit=0. --platform linux/amd64 tests the build most servers and cloud builders use, even on an Apple-silicon Mac (whose own arm64 image's Node is compiled from source):

docker run --rm --platform linux/amd64 node:22-alpine node -e "const locale = Intl.DateTimeFormat('sv').resolvedOptions().locale; if (locale !== 'sv') { console.error('This Node has no full ICU: Intl resolved sv to ' + locale + ', so dates would print in English for every language. Use a Node built with full ICU, as the official node images are.'); process.exit(1); }"; echo "exit=$?"

Or build the whole image (docker compose -f docker-compose.prod.yml build, or the next deploy) and see the step pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt

Intl formats dates and numbers only in the languages whose ICU data
Node carries, and a Node with English-only ICU prints every other
language in English without an error. The runner stage, where the app
and the worker run, now checks that Intl resolves Swedish to itself and
stops the build with a message if it doesn't. CI never builds the image,
so this is the only place the check can run.

Part of #622.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
@richshaw richshaw added pipeline:tophat pipeline:working A session is working on it right now labels Nov 13, 2026 — with Claude
@richshaw
richshaw requested a balanced review from Copilot November 13, 2026 22:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copy link
Copy Markdown
Owner Author

Tophat: passed

The image build itself wasn't run. This container has no Docker daemon (docker info can't reach the socket), and CI doesn't build the image. Nothing in the app changes, so I didn't start the app either. Instead I checked 0f6e749 three ways: I ran the RUN line itself, parsed the Dockerfile with BuildKit's own parser, and ran the owner's command from "Before merging". Everything ran on Node 22.23.4 (ICU 78.3, full ICU).

Check Result What I saw
The line passes on a full-ICU Node ✅ I ran the exact string BuildKit hands to the shell under /bin/sh -c (dash), bash -c and BusyBox sh -c. BusyBox is where Alpine's /bin/sh comes from. Each gave exit 0, with 0 bytes on stdout and on stderr. The result was the same with LANG=C, LC_ALL=POSIX, LANG=ja_JP.UTF-8 and TZ=Pacific/Auckland, so the build's locale settings can't trip it.
It fails on a Node without Swedish ✅ I built my own English-only ICU index with genrb (ICU 74.2 tools): an icudt78l/res_index.res whose InstalledLocales holds only en and en_US, and pointed NODE_ICU_DATA at it. Under dash and under BusyBox the line exits 1, and stderr is exactly: This Node has no full ICU: Intl resolved sv to en-US, so dates would print in English for every language. Use a Node built with full ICU, as the official node images are. With the same data, Swedish formatting quietly falls back to English: lör 2 maj / 14:30 / 1 234,5 become Sat, May 2 / 2:30 PM / 1,234.5. So the check catches the harm that matters. An empty NODE_ICU_DATA folder changes nothing (exit 0), as the PR says. With Intl deleted, standing in for a --without-intl Node, it still fails (exit 1, ReferenceError: Intl is not defined), only without the friendly message.
It guards every image that runs the app ✅ The stages are base (node:22-alpine), then deps, builder and runner, all FROM base. The check is runner's first instruction, and runner is the last stage, so it's what a build produces when no target is named. In docker-compose.prod.yml, migrate, web and worker all build from x-instance-build (context ., no target, no dockerfile), so all three run the runner image. Nothing in the repo sets a target or builds another stage: docker-compose.yml only pulls Postgres, and CI builds no image. A plain docker build, as in the README, builds the same stage. builder runs pnpm build on the same base Node, so the check covers that Node too.
The quoting survives Docker's parser ✅ I parsed the file with BuildKit's parser and instruction loader (github.com/moby/buildkit v0.34.2). There were no errors, 0 parser warnings and 0 lint warnings, the same as main. The RUN spans one line (52–52) in shell form (PrependShell=true), and the string it hands to /bin/sh -c is byte-identical to the Dockerfile text after RUN . The line has no $, backtick, backslash, #, tab or non-ASCII character, and doesn't end in a backslash. The parser attaches the five lines above it to the RUN as comments (PrevComment), so they are real comments. They come after FROM, so none of them can be read as a parser directive. Under BusyBox sh, Node gets exactly the intended JS, and it compiles.
The owner's "Before merging" command runs as written ✅ I took the command from this PR's body through the API. It's one line with no smart quotes, and its JS is byte-identical to the Dockerfile's. I ran it as written in sh (dash), interactive bash and interactive zsh -f (the macOS default). A stand-in docker checked that it gets run --rm node:22-alpine and then ran the rest on this Node. History expansion was on in both interactive shells: a control "!zzz" fails with "event not found". The !== isn't expanded, since neither shell expands a ! followed by =. With full ICU it prints only exit=0. With English-only data it prints the message and exit=1.

One wording nit, not a blocker: "Before merging" says the quick check "should print nothing", but the trailing echo prints exit=0, and Docker prints its pull progress the first time. "Should print only exit=0" would match what you'll see.

Only your command or a real image build can show that the stock node:22-alpine passes; nothing here could, as the PR says. CI on 0f6e749 is green: lint-type-test, e2e and CodeQL.

No screenshots, because nothing on screen changes. Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt


Generated by Claude Code

@richshaw richshaw left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: passed (round 1)

This adds #622's Dockerfile bullet and nothing else: one RUN node -e step at the top of runner that fails the image build unless Intl.DateTimeFormat('sv').resolvedOptions().locale is 'sv', a comment saying why, and a CHANGELOG line. It does what the issue asks, in the right place, and the stock base passes it.

What I checked:

  • The right stage. All three stages derive from base (node:22-alpine), so runner's Node is also the one builder runs pnpm build on. runner is the last stage, and nothing names another target: docker-compose.prod.yml's x-instance-build (migrate, web and worker), fly.example.toml and the README's docker build all build it. Putting the check in base wouldn't catch anything sooner in practice: under BuildKit (the default builder in current Docker and Compose), this step depends only on base, so it runs alongside deps' pnpm install, and its failure cancels the build as soon as base is ready. Only the legacy builder would get through pnpm build first. In runner it also keeps checking the Node that serves pages and sends emails if that stage's FROM ever changes. I agree with where it is.
  • node:22-alpine has full ICU today. docker-node's 22/alpine3.24/Dockerfile (the current 22-alpine, Node 22.23.5) installs nodejs.org's official linux-x64-musl binary on amd64, and on other architectures compiles from source with a plain ./configure (full ICU by default since Node 13). It never links Alpine's system ICU. I downloaded that musl tarball, checked it against nodejs.org's SHASUMS256, and read the binary without running it. Its embedded config says "icu_small": false and ICU 78, and its embedded data holds icudt78l/sv.res, sv_SE.res and coll/sv.res among 145 two-letter locales. That's the same count as this container's full-ICU Node 22.23.4, which resolves sv to sv.
  • The line itself. Run through /bin/sh -c exactly as the Dockerfile has it, on Node 22.23.4: exit 0, no output. The tophat's runs with English-only ICU data (exit 1, with the message) and its check with BuildKit's parser stand.
  • The message says what sv resolved to and what goes wrong, and gives the fix that always works: the official node images. See the first optional point for the one case it could name.
  • CHANGELOG: accurate, under Changed. It needs no "Before upgrading:": the stock build is unaffected, and anyone on another base gets a failed build with the reason, not a broken site.

Blocking (0).

Optional (3):

  1. Dockerfile 47–52: the likeliest way anyone hits this is Alpine's own nodejs package (FROM alpine plus apk add nodejs, to slim the image). It's built --with-intl=system-icu, and Alpine's ICU installs icu-data-en (en_US and en_GB only) unless icu-data-full is added, as Alpine's own post-install note says. Naming icu-data-full in the comment or the message would give that self-hoster a one-line fix instead of a base-image change.
  2. PR description, "Before merging": the quick command prints exit=0 (and Docker's pull progress the first time), not nothing, as the tophat noted. Also, on an Apple-silicon machine docker run node:22-alpine pulls the arm64 image, whose Node docker-node compiles from source, while amd64 builds (most servers and cloud builders) get the musl binary checked above. docker run --rm --platform linux/amd64 node:22-alpine … tries that one.
  3. README, "Other ways to run it": the check covers only the image. Someone running the app from source on their own Node 22 gets no check, and once Swedish ships, an English-only ICU there (that same Alpine package) would print dates in English without a word. That's outside this PR (#622 asks only for the Dockerfile). "With full ICU" next to "Node 22.12 or later" belongs with the README changes in Swedish's launch step (#639). Not filed separately.

Earlier threads: none. Copilot couldn't review (its quota was used up).
Checks: CI on 0f6e749 is green: lint-type-test, e2e, CodeQL. Locally: the RUN line under /bin/sh -c, the read of the official musl binary above, and the shared runtime-change check since the tophat (0, same SHA). The tophat at 0f6e749 passed. No image was built: there's no Docker daemon here, and CI builds none.

Waits for the owner because it changes the Dockerfile (high-risk) and asks you to run a check before merging. Nothing on screen changes, so there are no screenshots. What to look at: the six Dockerfile lines and, if you can, the "Before merging" command (or docker compose -f docker-compose.prod.yml build) to see the stock base pass for real. That's the one thing nothing here could run.

Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt


Generated by Claude Code

@richshaw richshaw added pipeline:owner Passed; waits for the owner (UX or high-risk) and removed pipeline:review pipeline:working A session is working on it right now labels Nov 13, 2026 — with Claude
@richshaw richshaw added the pipeline:working A session is working on it right now label Nov 16, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Approved by the owner at 0f6e749.

The owner approved merging the localization stack (#897 up to #931) in the orchestrating session on 15 November 2026, and chose to include this PR in it.

https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt


Generated by Claude Code

@richshaw richshaw added pipeline:merge and removed pipeline:owner Passed; waits for the owner (UX or high-risk) labels Nov 16, 2026 — with Claude
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt

Copy link
Copy Markdown
Owner Author

catch-up: merged main (75488be, the localization stack up to #926) into this branch as 7c3a5a8, cleanly. Merges only, own diff unchanged (Dockerfile and one CHANGELOG line), markers on 0f6e749 stand.

https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt


Generated by Claude Code

@richshaw
richshaw merged commit 2942442 into main Nov 16, 2026
5 checks passed
@richshaw
richshaw deleted the claude/issue-622-dockerfile-icu branch November 16, 2026 02:36
@richshaw richshaw removed pipeline:merge pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude
richshaw pushed a commit that referenced this pull request Nov 16, 2026
main moved on by 62 commits since this branch was built: the whole
localization stack (#897 to #999) plus #806, #890, #983 and #984.

Files main added in folders this branch moved now sit in the route groups:
eleven under src/app/(organizer)/app/(chrome)/, six under
src/app/(organizer)/login/ and one under src/app/(organizer)/oauth/.
main's footer `locale` on src/app/s/layout.tsx moves into
src/app/s/[slug]/layout.tsx, which absorbed it, and the global 404 passes
one too. CHANGELOG.md keeps both sides' entries, CLAUDE.md the new consent
paths and main's Languages line, and a11y.spec.ts both new tests.

The lint rule lists in eslint.config.mjs, the file list in
no-hard-coded-text.test.ts, two test imports and two comments now name the
new paths. The signup page's metadata test expects the tab title the page
writes itself (`title.absolute`), as it does on this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SVnYjqfPQCMgeA7pDt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants