Skip to content

Fix Docker build: canvas native compile and Vite heap OOM on node:20-slim#372

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-canvas-native-compile-error
Draft

Fix Docker build: canvas native compile and Vite heap OOM on node:20-slim#372
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-canvas-native-compile-error

Conversation

Copilot AI commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

docker compose up --build failed in the frontend-builder stage: canvas (node-gyp rebuild) had no native toolchain or Cairo headers on node:20-slim, and the Vite build hit JavaScript heap out of memory against Node's ~2 GB default heap regardless of Docker memory.

Changes

  • Dockerfile — canvas build deps: install python3 make g++ pkg-config and Cairo/Pango/JPEG/GIF/RSVG dev libraries before yarn install so the native module compiles.
  • Dockerfile — heap limit: add ARG NODE_HEAP_MB=8192 and ENV NODE_OPTIONS=--max-old-space-size=${NODE_HEAP_MB} before yarn build, overridable per build.
  • docker-compose.yml: surface NODE_HEAP_MB: "8192" under build.args.
  • yarn.lock — frozen-lockfile blocker: realign the four @tiptap/extension-table* keys from ^3.23.6 to ^3.22.2 to match package.json, keeping the existing 3.23.6 resolutions. Without this, yarn install --frozen-lockfile aborts before reaching the canvas/build steps.
RUN apt-get update && apt-get install -y --no-install-recommends \
        python3 make g++ pkg-config \
        libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev librsvg2-dev \
    && rm -rf /var/lib/apt/lists/*

ARG NODE_HEAP_MB=8192
ENV NODE_OPTIONS=--max-old-space-size=${NODE_HEAP_MB}

The yarn.lock realignment is intentionally limited to key strings (no version bumps, no registry/URL churn) to keep the dependency tree byte-identical aside from the range match.

- Install build toolchain and Cairo dev libs in frontend-builder stage so the
  native 'canvas' module compiles during yarn install on node:20-slim.
- Add NODE_HEAP_MB build-arg (default 8192) and set NODE_OPTIONS to avoid
  'JavaScript heap out of memory' during the Vite build.
- Expose NODE_HEAP_MB build arg in docker-compose.yml.
- Realign @tiptap/extension-table* yarn.lock keys to ^3.22.2 to match
  package.json so 'yarn install --frozen-lockfile' succeeds.
Copilot AI changed the title [WIP] Fix Docker build failure due to canvas native compile error Fix Docker build: canvas native compile and Vite heap OOM on node:20-slim Jun 28, 2026
Copilot AI requested a review from Chenglong-MS June 28, 2026 01:08
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