Docker build fails: `canvas` native compile error and Vite `yarn build` JavaScript heap OOM on `node:20-slim`

Đang mở
#371 0 bình luận 1 reaction 2 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@Chenglong-MS đang làm issue này rồi.

Từ ngày 28/6/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Environment
  • Command: docker compose up --build / docker build
  • Base image: node:20-slim (Dockerfile frontend-builder stage)
  • Dependency: package.json includes "canvas": "^3.2.1"
Problem 1: canvas fails to compile during yarn install

Symptoms

gyp ERR! cwd /app/node_modules/canvas
gyp ERR! not ok
error Command failed with exit code 1.

Root cause

node:20-slim does not include the native build toolchain or Cairo development libraries required by the canvas npm package. Running yarn install triggers node-gyp rebuild, which fails on the slim image.

Proposed fix

Install system dependencies in the frontend-builder stage before yarn install:

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/*

Problem 2: JavaScript heap OOM during yarn build

Symptoms

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

This occurs even when Docker Desktop memory is set to 12 GB or higher.

Root cause

Node.js defaults to a heap limit of roughly 2 GB, independent of the total memory allocated to Docker. Vite production builds for this project can exceed that limit.

Proposed fix

Raise the Node.js heap limit before yarn build, with an optional build-arg override:

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

Optional in docker-compose.yml:

build:
  args:
    NODE_HEAP_MB: "8192"

Steps to reproduce
  1. Clone the repo and configure .env
  2. Run docker compose up --build
  3. Build fails at yarn install (canvas) and/or yarn build (Vite OOM)
Expected behavior

docker compose up --build completes successfully and the service starts on port 5567.`

Ngôn ngữ chính
Python
Star
17.7k
Fork
1.7k
Merge trung bình
4 ngày 1 giờ
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/data-formulator

Tất cả issue của microsoft/data-formulator

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.