1

I am trying to run a container based on my app image by using docker and i getting the next error:

/app/node_modules/sharp/lib/libvips.js:68 throw new Error('${vendorPlatformId}' binaries cannot be used on the '${currentPlatformId}' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the '${currentPlatformId}' platform.);

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

My Dockerfile:

FROM node:10.20.1
WORKDIR /app

COPY package.json .

RUN npm install -g node-gyp
RUN npm install

EXPOSE 8080

CMD [ "npm", "start" ]

I tryied to add the next Commands to my Dockerfile but i am getting the same error:

Second attempt Dockerfile:

FROM node:10.20.1
WORKDIR /app

COPY package.json .

RUN npm install -g node-gyp
RUN rm -rf node_modules/sharp
RUN npm install --arch=x64 --platform=linux --target=8.10.0 sharp

EXPOSE 8080

CMD [ "npm", "start" ]

The docker command I using locally on my mac in order to run that container is:

docker run -d -p 8080:8080 --env-file ./.env --name server-dev-1 server:1

Any ideas?

Elmar Brauch
  • 1,286
  • 6
  • 20
Roy Stern
  • 11
  • 2
  • how did you install sharp? – Ashok Nov 17 '20 at 09:23
  • 1
    Do you have a [`.dockerignore` file](https://docs.docker.com/engine/reference/builder/#dockerignore-file)? You should exclude the host's `node_modules` tree, both to avoid this issue and also to make the build process somewhat faster. – David Maze Nov 17 '20 at 12:11

0 Answers0