Skip to content
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

Doesn't work on node:12-alpine docker #1486

Closed
dompedro-jonathborg opened this issue Oct 29, 2019 · 6 comments
Closed

Doesn't work on node:12-alpine docker #1486

dompedro-jonathborg opened this issue Oct 29, 2019 · 6 comments

Comments

@dompedro-jonathborg
Copy link

dompedro-jonathborg commented Oct 29, 2019

Dockerfile Example:

FROM node:12-alpine

RUN apk add --update --no-cache \
    ca-certificates \
    cairo-dev \
    giflib-dev \
    nss

RUN yarn global add nodemon

I got a not found 404.
Seems like a "musl" problem.

@zbjornson
Copy link
Collaborator

If you got a 404 after running yarn global add nodemon, then this is the wrong repository to open an issue in.

If you were trying to install node-canvas, can you post the full output please?

@dompedro-jonathborg
Copy link
Author

I got a 404 when I install node-canvas. yarn add canvas

Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /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 WARN Using needle for node-pre-gyp https download
node-pre-gyp info check checked for "/node_modules/canvas/build/Release/canvas.node" (not found)
node-pre-gyp http GET https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-node-v72-linux-musl-x64.tar.gz
node-pre-gyp http 404 https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-node-v72-linux-musl-x64.tar.gz
node-pre-gyp WARN Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-node-v72-linux-musl-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, musl) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.6.0/canvas-v2.6.0-node-v72-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 info find Python using Python version 3.6.9 found at "/usr/bin/python3"
gyp http GET https://nodejs.org/download/release/v12.13.0/node-v12.13.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v12.13.0/node-v12.13.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v12.13.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v12.13.0/SHASUMS256.txt
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/node_modules/canvas/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.cache/node-gyp/12.13.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/12.13.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/12.13.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/node_modules/canvas',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
Traceback (most recent call last):
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 50, in
sys.exit(gyp.script_main())
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 554, in script_main
return main(sys.argv[1:])
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 547, in main
return gyp_main(args)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 523, in gyp_main
options.duplicate_basename_check)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 139, in Load
params['parallel'], params['root_targets'])
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2779, in Load
variables, includes, depth, check, True)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 417, in LoadTargetBuildFile
build_file_data, PHASE_EARLY, variables, build_file_path)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1296, in ProcessVariablesAndConditionsInDict
build_file)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1311, in ProcessVariablesAndConditionsInList
ProcessVariablesAndConditionsInDict(item, phase, variables, build_file)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1270, in ProcessVariablesAndConditionsInDict
ProcessConditionsInDict(the_dict, phase, variables, build_file)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1149, in ProcessConditionsInDict
variables, build_file)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1296, in ProcessVariablesAndConditionsInDict
build_file)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 1315, in ProcessVariablesAndConditionsInList
expanded = ExpandVariables(item, phase, variables, build_file)
File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 914, in ExpandVariables
sys.stderr.write(p_stderr)
TypeError: write() argument must be str, not bytes while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 5.0.0-32-generic
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" "--module=/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/node_modules/canvas/build/Release" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd /node_modules/canvas
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
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 --module=/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/node_modules/canvas/build/Release --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack at ChildProcess. (/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Linux 5.0.0-32-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/node_modules/canvas/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /node_modules/canvas
node-pre-gyp ERR! node -v v12.13.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
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 --module=/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/node_modules/canvas/build/Release --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

@zbjornson
Copy link
Collaborator

Ah, that's because your system is using musl libc. See node-gfx/node-canvas-prebuilt#77 for info on that. Since a musl prebuild isn't available, you'll have to build from source (see https://github.com/Automattic/node-canvas#compiling).

@dompedro-jonathborg
Copy link
Author

Helping some people:

FROM node:12-alpine

RUN apk add --update --no-cache \
    make \
    g++ \
    jpeg-dev \
    cairo-dev \
    giflib-dev \
    pango-dev

CMD [ "node" ]

inside container run npm_config_build_from_source=true yarn add canvas or npm i canvas --build-from-source

It' works! Thank you!

@tvkit
Copy link

tvkit commented Apr 5, 2020

Helping some people:

Thanks, you definitely helped.

Helping++ with a python dependency and the yarn call inlined.

RUN apk --no-cache --virtual build-dependencies add \
    jpeg-dev \
    cairo-dev \
    giflib-dev \
    pango-dev \
    python \
    make \
    g++ \
    && npm_config_build_from_source=true yarn \
    && quasar build \
    && apk del build-dependencies

@IgorBelinskiy
Copy link

IgorBelinskiy commented Feb 23, 2023

RUN apk add --update python2 && rm -rf /var/cache/apk/*
RUN apk add --update --no-cache \
        make \
        g++ \
        jpeg-dev \
        cairo-dev \
        giflib-dev \
        pango-dev

before 
COPY package*.json /usr/src/app/
RUN npm install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants