Skip to content

Fix production Docker build (glibc/musl mismatch)#206

Merged
LunaUrsa merged 2 commits into
mainfrom
fix/docker-build-musl
Jul 3, 2026
Merged

Fix production Docker build (glibc/musl mismatch)#206
LunaUrsa merged 2 commits into
mainfrom
fix/docker-build-musl

Conversation

@sympact06

@sympact06 sympact06 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Problem

The production build fails with:

Error: Cannot find module '../lightningcss.linux-x64-musl.node'
Error: Could not load the "sharp" module using the linuxmusl-x64 runtime

Root cause

The development stage installs node_modules on node:lts (Debian, glibc), and the build stage (node:lts-alpine, musl) copies them over. Native binaries (lightningcss, sharp, @next/swc) are libc-specific, so the copied modules can't load on Alpine.

This never surfaced before because the build didn't actually load these native modules. After the dependency bump (Next 15.5, Tailwind 4.3) and the new CSS module from #205, it does.

Fix

Use node:lts-alpine for the development stage too, so all stages share the same libc and copying node_modules between them stays valid.

Also fixes a small npm flag typo: --omit:dev -> --omit=dev (it only worked by accident because NODE_ENV=production already omits dev deps).

Also included

Two pre-existing type errors in DrugInfo.tsx failed next build type-checking after the Docker fix, so they're fixed here too (types only, no behavior change):

  • comboObject was cast to a map over all Status keys but omitted Status.Self. It's now typed as Exclude<Status, Status.Self> instead of adding a Self entry, because the render loop maps over Object.keys(comboObject) and comboColors has no Self entry (rendering it would crash).
  • comboData[drugB] indexed the Interactions interface with a plain string; now uses keyof Interactions with a guard for the optional entries.

Verified with npx tsc --noEmit: 0 errors.

sympact06 added 2 commits July 3, 2026 23:02
The development stage installed node_modules on node:lts (Debian/glibc),
which the Alpine (musl) build stage then copied. Native binaries
(lightningcss, sharp, @next/swc) are libc-specific, so next build failed
with "Cannot find module '*-musl.node'" once the dependency bump and the
new CSS module actually loaded them.

Also fixes the npm flag typo --omit:dev -> --omit=dev.
- comboObject was cast to a map over all Status keys but omitted
  Status.Self. Type it as Exclude<Status, Status.Self> instead of adding
  a Self entry: the render loop maps over Object.keys(comboObject) and
  comboColors has no Self entry, so rendering it would crash.
- comboData[drugB] indexed the Interactions interface with a plain
  string; use keyof Interactions with a guard for the optional entries.

Types only, no behavior change.
@LunaUrsa LunaUrsa merged commit 3b71bd5 into main Jul 3, 2026
3 checks passed
@LunaUrsa LunaUrsa deleted the fix/docker-build-musl branch July 3, 2026 22:03
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.

2 participants