Problem with Sharp and Alpine node v10
See original GitHub issueHey,
First of all, thanks for a great lib!
I’m having issues using it with Docker and an Alpine build, though. I’ve read that vips needs to be added explicitly, but I can’t seem to get it to work.
My Dockerfile
FROM mhart/alpine-node:10 as base
WORKDIR /usr/src
RUN apk add vips-dev fftw-dev --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
RUN yarn build && yarn --production
FROM mhart/alpine-node:base-10
WORKDIR /usr/src
COPY --from=base /usr/src .
CMD node dist/index.js
EXPOSE 4001
Running build
fails with the output:
Step 1/31 : FROM mhart/alpine-node:10 as base
---> 36c9fa596689
Step 2/31 : WORKDIR /usr/src
Removing intermediate container 08f154f7b6c0
---> f9151dc7c5ef
Step 3/31 : RUN apk add vips-dev fftw-dev --update-cache --repository https://dl-3.alpinelinux.org/alpine/edge/testing/
---> Running in f097cab96b72
fetch https://dl-3.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/57) Installing fftw-double-libs (3.3.6p2-r0)
(2/57) Installing fftw-long-double-libs (3.3.6p2-r0)
(3/57) Installing fftw-single-libs (3.3.6p2-r0)
(4/57) Installing pkgconf (1.3.10-r0)
(5/57) Installing fftw-dev (3.3.6p2-r0)
(6/57) Installing libjpeg-turbo (1.5.2-r0)
(7/57) Installing libjpeg-turbo-dev (1.5.2-r0)
(8/57) Installing libexif (0.6.21-r1)
(9/57) Installing libexif-dev (0.6.21-r1)
(10/57) Installing zlib-dev (1.2.11-r1)
(11/57) Installing tiff (4.0.9-r5)
(12/57) Installing tiff-dev (4.0.9-r5)
(13/57) Installing lcms2 (2.8-r1)
(14/57) Installing lcms2-dev (2.8-r1)
(15/57) Installing libbz2 (1.0.6-r6)
(16/57) Installing perl (5.26.2-r1)
(17/57) Installing expat (2.2.5-r0)
(18/57) Installing libffi (3.2.1-r4)
(19/57) Installing gdbm (1.13-r1)
(20/57) Installing ncurses-terminfo-base (6.0_p20171125-r1)
(21/57) Installing ncurses-terminfo (6.0_p20171125-r1)
(22/57) Installing ncurses-libs (6.0_p20171125-r1)
(23/57) Installing readline (7.0.003-r0)
(24/57) Installing sqlite-libs (3.21.0-r1)
(25/57) Installing python2 (2.7.15-r2)
(26/57) Installing gettext-asprintf (0.19.8.1-r1)
(27/57) Installing libintl (0.19.8.1-r1)
(28/57) Installing libunistring (0.9.7-r0)
(29/57) Installing gettext-libs (0.19.8.1-r1)
(30/57) Installing libgomp (6.4.0-r5)
(31/57) Installing libxml2 (2.9.7-r0)
(32/57) Installing gettext (0.19.8.1-r1)
(33/57) Installing gettext-dev (0.19.8.1-r1)
(34/57) Installing bzip2-dev (1.0.6-r6)
(35/57) Installing libffi-dev (3.2.1-r4)
(36/57) Installing libuuid (2.31-r0)
(37/57) Installing libblkid (2.31-r0)
(38/57) Installing libfdisk (2.31-r0)
(39/57) Installing libmount (2.31-r0)
(40/57) Installing libsmartcols (2.31-r0)
(41/57) Installing util-linux-dev (2.31-r0)
(42/57) Installing pcre (8.41-r1)
(43/57) Installing glib (2.54.2-r0)
(44/57) Installing libpcre16 (8.41-r1)
(45/57) Installing libpcre32 (8.41-r1)
(46/57) Installing libpcrecpp (8.41-r1)
(47/57) Installing pcre-dev (8.41-r1)
(48/57) Installing glib-dev (2.54.2-r0)
(49/57) Installing libpng (1.6.34-r1)
(50/57) Installing libpng-dev (1.6.34-r1)
(51/57) Installing libwebp (0.6.0-r1)
(52/57) Installing libwebp-dev (0.6.0-r1)
(53/57) Installing orc (0.4.27-r0)
(54/57) Installing orc-dev (0.4.27-r0)
(55/57) Installing giflib (5.1.4-r1)
(56/57) Installing vips (8.6.3-r0)
(57/57) Installing vips-dev (8.6.3-r0)
Executing busybox-1.27.2-r11.trigger
Executing glib-2.54.2-r0.trigger
No schema files found: doing nothing.
OK: 135 MiB in 72 packages
Removing intermediate container f097cab96b72
---> 058b043a4f79
Step 4/31 : COPY package.json yarn.lock ./
---> 25fdb6fc4548
Step 5/31 : RUN yarn install
---> Running in 3f4d4f5839ed
yarn install v1.9.4
[1/4] Resolving packages...
[2/4] Fetching packages...
(node:7) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
info fsevents@1.2.4: The platform "linux" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /usr/src/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
Arguments:
Directory: /usr/src/node_modules/sharp
Output:
info sharp Detected globally-installed libvips v8.6.3
info sharp Building from source via node-gyp
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.9.0 | linux | x64
gyp http GET https://nodejs.org/download/release/v10.9.0/node-v10.9.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v10.9.0/node-v10.9.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v10.9.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v10.9.0/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/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 '/usr/src/node_modules/sharp/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.node-gyp/10.9.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/.node-gyp/10.9.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/root/.node-gyp/10.9.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/usr/src/node_modules/sharp',
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=.' ]
/bin/sh: c++filt: not found
/bin/sh: readelf: not found
gyp: Call to 'if readelf -Ws "$(PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config --variable libdir vips-cpp)/libvips-cpp.so" | c++filt | grep -qF __cxx11;thenecho "1";else echo "0";fi' returned exit status 0 while in binding.gyp. 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/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:239:12)
gyp ERR! System Linux 4.9.87-linuxkit-aufs
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/src/node_modules/sharp
gyp ERR! node -v v10.9.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
What am I doing wrong?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Docker build fail: sharp Use with musl 1.2.2 requires manual ...
the issue was resolved by updating node-alpine to 14 and updating sharp library to 0.29.1.
Read more >sharp - npm
High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images. Latest version: 0.31.3, ...
Read more >[Solved]-Express Sharp install via Docker issue-node.js
[Solved]-Express Sharp install via Docker issue-node.js ... Alpine uses musl for its C library. You can either use a different non-alpine based image...
Read more >Installation - High performance Node.js image processing
Common problems. The architecture and platform of Node.js used for npm install must be the same as the architecture and platform of Node.js...
Read more >My Docker Setup for Gatsby | Walter Teng
Error in "/app/node_modules/gatsby-transformer-sharp/gatsby-node.js": ... the same solution from this issue, I decided to change from an Alpine Node image ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d like to, but my hosting provider, Zeit Now, enforces an image limit of 100mb for deployments.
I managed to make it work in the meantime, however, with a little inspiration from other Github issues, and this comment in particular.
In short, I had to:
Dockerfile
is removed in the next stage anywayvips
in the final stage.I still think it’d be great if the readme part for the Alpine installation would be a tad more thorough/explicit, if nothing else, to save your time answering this question over and over going forward 😃
As a reference for others, my full Dockerfile now looks like this:
A multistage
Dockerfile
is yet another level of complexity so glad you got it working.#1379 should make things a lot easier for Alpine-based installations.