-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linux-musl build #77
Comments
Hi @chearon , do you have any thoughts whether it could be easily added? I can't tag LinusU for some reason |
I'll definitely accept a PR and help out as much as I can, but I haven't done any work on it. The easiest path would be to find a docker image that has musl (alpine?) and copy the |
Would love to see the musl build as well. For now i'll attempt to build from node-gyp. Hopefully I don't need to add too many packages to Alpine. :) |
Just an FYI...these are the packages I had to add on Alpine. I might not have got them all but here is some of my history. apk add --no-cache make gcc g++ python pkgconfig pixman-dev cairo-dev pango-dev libjpeg-turbo-dev giflib-dev This allowed me to build. Now to test if it runs ok 👍 |
Starting from apk add --no-cache nodejs npm build-base g++ cairo-dev jpeg-dev pango-devbash imagemagick
npm i -g node-gyp Just for reference: Automattic/node-canvas#866 |
Hi, i had this problem on an alpine based docker image (Homebridge / oznu). I don't think bash / imageMagick are needed however. |
(node:181) UnhandledPromiseRejectionWarning: Error: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /app/node_modules/canvas/build/Release/libpixman-1.so.0) |
Using |
….2` to succeed [+] Added packages mentioned in [this comment](node-gfx/node-canvas-prebuilt#77 (comment)) of [linux\-musl build \ExLibrisGroup#77](node-gfx/node-canvas-prebuilt#77) to fix this problem in `docker compose` `web` build: ```shell Command: node-pre-gyp install --fallback-to-build --update-binary Arguments: Directory: /tmp/node_modules/canvas Output: node-pre-gyp info it worked if it ends with ok node-pre-gyp info using [email protected] node-pre-gyp info using [email protected] | linux | x64 node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v93-linux-musl-x64.tar.gz node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v93-linux-musl-x64.tar.gz node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v93 ABI, musl) (falling back to source compile with node-gyp) node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v93-linux-musl-x64.tar.gz gyp info it worked if it ends with ok gyp info using [email protected] gyp info using [email protected] | linux | x64 gyp info ok gyp info it worked if it ends with ok gyp info using [email protected] gyp info using [email protected] | linux | x64 gyp ERR! find Python gyp ERR! find Python Python is not set from command line or npm configuration gyp ERR! find Python Python is not set from environment variable PYTHON gyp ERR! find Python checking if "python3" can be used gyp ERR! find Python - "python3" is not in PATH or produced an error gyp ERR! find Python checking if "python" can be used gyp ERR! find Python - "python" is not in PATH or produced an error gyp ERR! find Python gyp ERR! find Python ********************************************************** gyp ERR! find Python You need to install the latest version of Python. gyp ERR! find Python Node-gyp should be able to find and use Python. If not, gyp ERR! find Python you can try one of the following options: gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable" gyp ERR! find Python (accepted by both node-gyp and npm) gyp ERR! find Python - Set the environment variable PYTHON gyp ERR! find Python - Set the npm configuration variable python: gyp ERR! find Python npm config set python "/path/to/pythonexecutable" gyp ERR! find Python For more information consult the documentation at: gyp ERR! find Python https://github.com/nodejs/node-gyp#installation gyp ERR! find Python ********************************************************** gyp ERR! find Python gyp ERR! configure error gyp ERR! stack Error: Could not find any Python installation to use gyp ERR! stack at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47) gyp ERR! stack at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21) gyp ERR! stack at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:202:16) gyp ERR! stack at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:294:16) gyp ERR! stack at exithandler (node:child_process:408:5) gyp ERR! stack at ChildProcess.errorhandler (node:child_process:420:5) gyp ERR! stack at ChildProcess.emit (node:events:513:28) gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12) gyp ERR! stack at onErrorNT (node:internal/child_process:478:16) gyp ERR! stack at processTicksAndRejections (node:internal/process/task_queues:83:21) gyp ERR! System Linux 5.4.0-1025-aws gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--update-binary" "--module=/tmp/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/tmp/node_modules/canvas/build/Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93" gyp ERR! cwd /tmp/node_modules/canvas gyp ERR! node -v v16.17.0 gyp ERR! node-gyp -v v9.0.0 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/tmp/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/tmp/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1) node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/tmp/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23) node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28) node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1093:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) node-pre-gyp ERR! System Linux 5.4.0-1025-aws node-pre-gyp ERR! command "/usr/local/bin/node" "/tmp/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--update-binary" node-pre-gyp ERR! cwd /tmp/node_modules/canvas node-pre-gyp ERR! node -v v16.17.0 node-pre-gyp ERR! node-pre-gyp -v v1.0.10 node-pre-gyp ERR! not ok Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/tmp/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/tmp/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1) info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. ERROR: Service 'web' failed to build: The command '/bin/sh -c cd /tmp && yarn install --frozen-lockfile --ignore-optional && mkdir -p $INSTALL_PATH && cd $INSTALL_PATH && cp -R /tmp/node_modules $INSTALL_PATH && rm -r /tmp/* && yarn cache clean' returned a non-zero code: 1 ``` For details, see `canvas` issue: [How to Troubleshoot Installation \#1511](Automattic/node-canvas#1511)
If anyone else is looking to cut down on their final image size, this is how I was able to use a multi-stage build to do so. Doing this reduces the final image size by about 300 mb. Note that I have not included the GIF and SVG libs, since I don't need them for my case. FROM node:20-alpine AS build
RUN apk add --no-cache make gcc g++ python3 pkgconfig pixman-dev cairo-dev pango-dev libjpeg-turbo-dev
COPY package.json package-lock.json ./
RUN npm ci
FROM node:20-alpine
## These are runtime dependencies required by node-canvas
RUN apk add --no-cache cairo pango libjpeg-turbo
COPY --from=build /node_modules ./node_modules
...etc. |
Hi @chearon,
as many others we use docker for our development and continuous integration process. Linux Alpine uses musl as standard library which is currently not supported. I would find an linux-musl build useful.
Resources:
https://www.musl-libc.org/
https://alpinelinux.org/posts/Alpine-Linux-has-switched-to-musl-libc.html
The text was updated successfully, but these errors were encountered: