question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Express Sharp install via Docker issue

See original GitHub issue

Hi, I need to use sharp. Its work fine on my workspace but if I deploymeny via docker then I get error. I am implementation all steps.

Error: 'linux-x64' binaries cannot be used on the 'linuxmusl-x64' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'linuxmusl-x64' platform.

I think sharp is prebuilt when first install. It uses the architecture of my computer(darwin, arm) But when it runs on the docker, although it gets built again, the work talks about the architecture of my computer.

My Dockerfile:

FROM node:alpine

RUN mkdir -p /usr/src/node-app && chown -R node:node /usr/src/node-app

WORKDIR /usr/src/node-app

COPY package.json yarn.lock ./

USER node

RUN npm install --pure-lockfile
RUN npm install sharp --ignore-scripts=false

COPY --chown=node:node . .

EXPOSE 3050

My .dockerignore.

node_modules
**/node_modules
npm-debug.log
Dockerfile
.dockerignore
.git
.gitignore

docker build . When I do it, I see that sharp for my server is loaded among the docker logs.

found 11 vulnerabilities (6 moderate, 5 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Removing intermediate container e5ad8008eebd
 ---> 906e268b6fc3
Step 7/9 : RUN npm install sharp --ignore-scripts=false
 ---> Running in 933338813b5d

> sharp@0.27.0 install /usr/src/node-app/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Using cached /home/node/.npm/_libvips/libvips-8.10.5-linuxmusl-x64.tar.br
npm WARN @apidevtools/swagger-parser@10.0.2 requires a peer of openapi-types@>=7 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.19.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ sharp@0.27.0
updated 1 package and audited 1348 packages in 20.689s

84 packages are looking for funding
  run `npm fund` for details

found 11 vulnerabilities (6 moderate, 5 high)
  run `npm audit fix` to fix them, or `npm audit` for details
Removing intermediate container 933338813b5d
 ---> 838713a4cebb
Step 8/9 : COPY --chown=node:node . .
 ---> eb755fc2589e
Step 9/9 : EXPOSE 3050
 ---> Running in bf0a5c9e96c6
Removing intermediate container bf0a5c9e96c6
 ---> 347f113598fd
Successfully built 347f113598fd

My Docker-compose up log

mongodb_1   | 2021-01-09T19:31:15.802+0000 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=a8281f9d01ef
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten] db version v4.2.1
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1  11 Sep 2018
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten] allocator: tcmalloc
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten] modules: none
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten] build environment:
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten]     distmod: ubuntu1804
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten]     distarch: x86_64
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten]     target_arch: x86_64
mongodb_1   | 2021-01-09T19:31:15.815+0000 I  CONTROL  [initandlisten] options: { net: { bindIp: "0.0.0.0", port: 27017 }, security: { authorization: "enabled" }, storage: { dbPath: "/data/db" } }
mongodb_1   | 2021-01-09T19:31:15.816+0000 I  STORAGE  [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
mongodb_1   | 2021-01-09T19:31:15.816+0000 I  STORAGE  [initandlisten] 
mongodb_1   | 2021-01-09T19:31:15.816+0000 I  STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
mongodb_1   | 2021-01-09T19:31:15.816+0000 I  STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
mongodb_1   | 2021-01-09T19:31:15.816+0000 I  STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=457M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
mongodb_1   | 2021-01-09T19:31:17.154+0000 I  STORAGE  [initandlisten] WiredTiger message [1610220677:154424][1:0x7f96e9f8db00], txn-recover: Recovering log 194 through 195
api_node-app_1 exited with code 0
mongodb_1   | 2021-01-09T19:31:17.389+0000 I  STORAGE  [initandlisten] WiredTiger message [1610220677:389583][1:0x7f96e9f8db00], txn-recover: Recovering log 195 through 195
mongodb_1   | 2021-01-09T19:31:17.527+0000 I  STORAGE  [initandlisten] WiredTiger message [1610220677:527496][1:0x7f96e9f8db00], txn-recover: Main recovery loop: starting at 194/6016 to 195/256
mongodb_1   | 2021-01-09T19:31:17.643+0000 I  STORAGE  [initandlisten] WiredTiger message [1610220677:643739][1:0x7f96e9f8db00], txn-recover: Recovering log 194 through 195
mongodb_1   | 2021-01-09T19:31:17.722+0000 I  STORAGE  [initandlisten] WiredTiger message [1610220677:722144][1:0x7f96e9f8db00], txn-recover: Recovering log 195 through 195
mongodb_1   | 2021-01-09T19:31:17.784+0000 I  STORAGE  [initandlisten] WiredTiger message [1610220677:784868][1:0x7f96e9f8db00], txn-recover: Set global recovery timestamp: (0,0)
mongodb_1   | 2021-01-09T19:31:17.812+0000 I  RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
mongodb_1   | 2021-01-09T19:31:17.825+0000 I  STORAGE  [initandlisten] Timestamp monitor starting
mongodb_1   | 2021-01-09T19:31:17.827+0000 I  CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
mongodb_1   | 2021-01-09T19:31:17.828+0000 I  CONTROL  [initandlisten] 
mongodb_1   | 2021-01-09T19:31:17.844+0000 I  SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
mongodb_1   | 2021-01-09T19:31:17.847+0000 I  STORAGE  [initandlisten] Flow Control is enabled on this deployment.
mongodb_1   | 2021-01-09T19:31:17.848+0000 I  SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
mongodb_1   | 2021-01-09T19:31:17.849+0000 I  SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
mongodb_1   | 2021-01-09T19:31:17.850+0000 I  SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
mongodb_1   | 2021-01-09T19:31:17.851+0000 I  FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
mongodb_1   | 2021-01-09T19:31:17.855+0000 I  SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
mongodb_1   | 2021-01-09T19:31:17.856+0000 I  NETWORK  [initandlisten] Listening on /tmp/mongodb-27017.sock
mongodb_1   | 2021-01-09T19:31:17.857+0000 I  NETWORK  [initandlisten] Listening on 0.0.0.0
mongodb_1   | 2021-01-09T19:31:17.857+0000 I  NETWORK  [initandlisten] waiting for connections on port 27017
mongodb_1   | 2021-01-09T19:31:17.858+0000 I  SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
mongodb_1   | 2021-01-09T19:31:18.004+0000 I  SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>

I think, I need to install sharp on docker for pre-built proccess. I didn’t understand how docker works very well. it has to do with my amateurishness that I live with.

Relation Issue : https://stackoverflow.com/questions/57932529/linux-x64-binaries-cannot-be-used-on-the-linuxmusl-x64-platform-error

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
lovellcommented, Jan 10, 2021

npm ERR! ERR! sharp EACCES: permission denied, mkdir ‘/root/.npm’

It looks like you’re using Node.js 15, which ships with npm 7 and had a breaking change as the --unsafe-perm flag was removed.

If you’re running npm install as root, make sure the directory you’re running it in is also owned by root.

For example, here’s what the sharp CI jobs have to do to workaround this:

https://github.com/lovell/sharp/blob/138e60adb3ff260fcbc6a127a47bffc3073839e0/.github/workflows/ci.yml#L69-L71

0reactions
lovellcommented, Jan 22, 2021

I hope this information helped. Please feel free to re-open with more details if further assistance is required.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Express Sharp install via Docker issue - Stack Overflow
I am implementation all steps. Error: 'linux-x64' binaries cannot be used on the 'linuxmusl-x64' platform. Please remove the 'node_modules/ ...
Read more >
[Solved]-Express Sharp install via Docker issue-node.js
Install private npm package in Docker via SSH · NPM install via git+https//x-oauth-basic within Docker container fails · Angular JS Express JS Node...
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 >
Installation - High performance Node.js image processing
Resize large images in common formats to smaller, web-friendly JPEG, PNG, WebP, GIF and AVIF images of varying dimensions.
Read more >
node - Official Image | Docker Hub
Node.js is a JavaScript-based platform for server-side and networking applications.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found