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

未关闭
#371 0 条评论 1 个 reaction 已指派 2 人 在 GitHub 查看

维护者通常 2 天内回复

@Chenglong-MS 已经在做这个了。

开始于 2026年6月28日。

评估

这个 Issue 还没有评估数据。

描述

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.`

主要语言
Python
星标
17.7k
派生
1.7k
平均合并
4 天 1 小时
30 天内合并 PR
8

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/data-formulator 的其他 Issue

查看 microsoft/data-formulator 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。