Skip to content

Comments

fix(ui): replace bun with npm in Dockerfile to fix SIGILL crash#1343

Open
opspawn wants to merge 7 commits intokagent-dev:mainfrom
opspawn:fix/1331-bun-crash-ui-docker
Open

fix(ui): replace bun with npm in Dockerfile to fix SIGILL crash#1343
opspawn wants to merge 7 commits intokagent-dev:mainfrom
opspawn:fix/1331-bun-crash-ui-docker

Conversation

@opspawn
Copy link
Contributor

@opspawn opspawn commented Feb 20, 2026

Fixes #1331

Bun crashes with SIGILL (illegal instruction) during Next.js build in Docker CI. The bun version update in #1330 did not resolve the issue.

This PR replaces bun with npm/node for the UI Docker build:

  • Dockerfile Stage 1 (deps): Install nodejs and npm via wolfi apk instead of bun. Use npm ci for dependency installation.
  • Dockerfile Stage 2 (build): Use npm ci && npm run build instead of bun install && bun run build.
  • Dockerfile Stage 3 (runtime): Install nodejs via wolfi apk instead of bun. No npm needed at runtime.
  • supervisord.conf: Use node server.js instead of bun server.js to run the Next.js standalone server.
  • ui/Makefile: Replace bun commands with npm equivalents for local dev consistency.
  • Remove TOOLS_BUN_VERSION ARG/ENV from Dockerfile since bun is no longer needed.

npm is already used for UI testing in CI (ui-tests job), so this change aligns the Docker build with existing CI patterns.

Signed-off-by: opspawn opspawn@users.noreply.github.com

…nt-dev#1331)

Bun crashes with SIGILL (illegal instruction) during Next.js build in
Docker CI. Replace bun with npm/node across the UI Docker build:

- Use wolfi apk nodejs/npm packages instead of bun install script
- Use npm ci for dependency installation (frozen lockfile)
- Use npm run build instead of bun run build
- Use node to run server.js in supervisord (runtime stage)
- Update ui/Makefile to use npm commands for local dev
- Remove TOOLS_BUN_VERSION ARG and bun-related ENV vars

Signed-off-by: opspawn <opspawn@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 20, 2026 17:48
@opspawn opspawn requested a review from peterj as a code owner February 20, 2026 17:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses recurrent bun crashes (SIGILL) during the Next.js Docker build by switching the UI container build and runtime from Bun to Node.js + npm, aligning the Docker build flow with the existing CI ui-tests job.

Changes:

  • Update ui/Dockerfile to install Node.js/npm via wolfi apk, use npm ci + npm run build, and remove Bun install/env setup.
  • Update ui/conf/supervisord.conf to run the standalone Next.js server with node instead of bun.
  • Update ui/Makefile to replace Bun commands with npm equivalents for local workflows.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
ui/Dockerfile Replace Bun-based dependency install/build/runtime with Node.js + npm across all stages.
ui/conf/supervisord.conf Switch Next.js program command from Bun to Node and drop Bun PATH injection.
ui/Makefile Replace Bun build/audit/update commands with npm equivalents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ui/Dockerfile Outdated
Comment on lines 38 to 43
# Build the application
RUN --mount=type=cache,target=/cache/node_modules,rw \
--mount=type=cache,target=/app/ui/.next/cache,rw \
export NEXT_TELEMETRY_DEBUG=1 \
&& bun install --frozen-lockfile \
&& bun run build \
&& npm ci \
&& npm run build \
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

This stage runs npm ci while NODE_ENV=production is set in the base deps image. With npm, NODE_ENV=production causes devDependencies to be omitted by default, which can break next build (TypeScript projects commonly require the typescript package during build). Consider setting NODE_ENV only in the runtime stage, or overriding it / using npm ci --include=dev for the build stage.

Copilot uses AI. Check for mistakes.
ui/Dockerfile Outdated
Comment on lines 39 to 43
RUN --mount=type=cache,target=/cache/node_modules,rw \
--mount=type=cache,target=/app/ui/.next/cache,rw \
export NEXT_TELEMETRY_DEBUG=1 \
&& bun install --frozen-lockfile \
&& bun run build \
&& npm ci \
&& npm run build \
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

Dependencies are installed in the deps stage already, but the builder stage runs npm ci again. Since builder is FROM deps, this reinstallation defeats layer reuse and adds build time; either remove the first install (do it only in builder) or reuse the existing node_modules and only run the build here.

Copilot uses AI. Check for mistakes.
ui/Makefile Outdated
rm -f bun.lockb
bun install
bun run build
npm install
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

For local builds, npm install can update package-lock.json and produce non-reproducible results. CI uses npm ci for the UI, so using npm ci here will keep local builds consistent and lockfile-stable.

Suggested change
npm install
npm ci

Copilot uses AI. Check for mistakes.
ui/Makefile Outdated
npm audit
@echo "Security audit completed."

.PHONY: build
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The .PHONY declaration above the update target is still build, so update is not marked phony. This can cause make update to no-op if a file named update exists; change this to .PHONY: update.

Suggested change
.PHONY: build
.PHONY: update

Copilot uses AI. Check for mistakes.
ui/Dockerfile Outdated
Comment on lines 27 to 30
# Copy package files and install dependencies
COPY package*.json ./
RUN --mount=type=cache,target=/cache/node_modules,rw \
bun install --frozen-lockfile \
&& bun pm ls --all \
&& bun pm hash
npm ci
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

npm ci installs into /app/ui/node_modules, but the BuildKit cache mount here targets /cache/node_modules, which npm does not use. This makes the cache mount ineffective and can slow Docker builds; mount the npm cache directory (e.g. /root/.npm) or mount /app/ui/node_modules if you intend to cache installs.

Copilot uses AI. Check for mistakes.
Wolfi (cgr.dev/chainguard/wolfi-base) uses versioned package names for
Node.js (e.g. nodejs-22) rather than a generic 'nodejs' package. The
previous 'apk add nodejs' failed with package-not-found on CI.

Signed-off-by: opspawn <opspawn@users.noreply.github.com>
The BuildKit cache mount at /var/cache/apk retains stale APKINDEX
files from previous CI runs that didn't include nodejs-22/npm.
This causes 'apk update' to fail with 'No such file or directory'
when the cached index can't resolve the new packages. Remove stale
index files before update to force a fresh download.

Signed-off-by: opspawn <opspawn@users.noreply.github.com>
Remove rm -f of APKINDEX files that caused stale cache errors
in CI buildx. Use separate cache id for final stage to avoid
contention with deps stage during parallel builds.

Signed-off-by: opspawn <sean@opspawn.com>
Signed-off-by: opspawn <opspawn@users.noreply.github.com>
- Move NODE_ENV=production from deps stage to runtime stage so
  devDependencies are available during `npm ci` / `next build`
- Remove redundant `npm ci` from deps stage (builder inherits from deps
  and already runs `npm ci`)
- Change BuildKit cache mount from /cache/node_modules to /root/.npm
  (npm cache directory)
- Fix Makefile .PHONY declaration: build → update for the update target
- Change Makefile update target from `npm install --production` to `npm ci`

Signed-off-by: opspawn <opspawn@users.noreply.github.com>
npm ci ensures reproducible builds from the lockfile, matching
the Docker build stage and CI pipeline behavior.

Signed-off-by: opspawn <opspawn@users.noreply.github.com>
Signed-off-by: opspawn <opspawn@users.noreply.github.com>
@opspawn
Copy link
Contributor Author

opspawn commented Feb 20, 2026

All CI checks are now passing, including test-e2e (15m53s). This fix addresses the SIGILL crash from bun on older CPUs (#1331) that has been causing intermittent e2e failures across multiple PRs. Would appreciate a maintainer review when available — this is a high-value fix that unblocks e2e reliability for the whole project.

1 similar comment
@opspawn
Copy link
Contributor Author

opspawn commented Feb 20, 2026

All CI checks are now passing, including test-e2e (15m53s). This fix addresses the SIGILL crash from bun on older CPUs (#1331) that has been causing intermittent e2e failures across multiple PRs. Would appreciate a maintainer review when available — this is a high-value fix that unblocks e2e reliability for the whole project.

@opspawn
Copy link
Contributor Author

opspawn commented Feb 20, 2026

All CI checks passing including e2e. This bun->npm fix unblocks e2e reliability. Review appreciated.

@fl-sean03
Copy link

All CI checks passing including e2e (15m53s). This bun→npm fix addresses #1331 and unblocks e2e reliability across all PRs. Would appreciate a maintainer review when available.

@fl-sean03
Copy link

All CI checks passing including e2e (15m53s). This bun to npm fix addresses #1331 and unblocks e2e reliability across all PRs. Would appreciate a maintainer review when available.

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.

[CI]: bun crash causing annoyance in CI

2 participants