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

Error: 'darwin-x64' binaries cannot be used on the 'linuxmusl-x64' platform. #11084

Closed
ettaibi opened this issue Jan 15, 2019 · 2 comments
Closed
Labels
status: needs more info Needs triaging and reproducible examples or more information to be resolved type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@ettaibi
Copy link

ettaibi commented Jan 15, 2019

Description

I am trying to dockerize my gatsby app containing gatsby-transformer-sharp v2.1.3, my Dockerfile is as follow:

FROM node:10.12.0-alpine

WORKDIR /var/www


RUN apk update \
    && apk add --no-cache git\
    && apk add --no-cache bash \
    && apk add --no-cache g++ gcc libgcc libstdc++ linux-headers make python\
    && apk add vips-dev fftw-dev build-base --update-cache \
    --repository https://alpine.global.ssl.fastly.net/alpine/edge/testing/ \
    --repository https://alpine.global.ssl.fastly.net/alpine/edge/main \
    && npm set progress=false \
    && npm install --quiet node-gyp -g \
    && npm install -g yarn gatsby-cli

# project node dependencies
COPY package.json yarn.lock /var/www/
RUN yarn && yarn cache clean
RUN rm -rf node_modules/sharp
RUN npm install --arch=x64 --platform=linux --target=8.10.0 sharp

# project files
COPY . /var/www/

CMD yarn build

after running docker-compose up (I have a docker-compose file too)which runs gatsby build command, I get the following error
Error: 'darwin-x64' binaries cannot be used on the 'linuxmusl-x64' platform. P lease remove the 'node_modules/sharp/vendor' directoryand run 'npm install'.

Steps to reproduce

Dockerize a gatsby app containing gatsby-transformer-sharp with the configuration I shared

Expected result

the app should be built successfully

Actual result

Error: 'darwin-x64' binaries cannot be used on the 'linuxmusl-x64' platform. P lease remove the 'node_modules/sharp/vendor' directory and run 'npm install'.

Environment

  System:
    OS: macOS 10.14.2
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.12.0 - ~/.nvm/versions/node/v10.12.0/bin/node
    Yarn: 1.10.1 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.12.0/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 71.0.3578.98
    Firefox: 61.0.2
    Safari: 12.0.2
  npmGlobalPackages:
    gatsby-cli: 2.4.8
@sidharthachatterjee sidharthachatterjee added the type: question or discussion Issue discussing or asking a question about Gatsby label Jan 16, 2019
@sidharthachatterjee
Copy link
Contributor

So from the error message it appears to be related to lovell/sharp#1303 (comment)

RUN yarn && yarn cache clean
RUN rm -rf node_modules/sharp
RUN npm install --arch=x64 --platform=linux --target=8.10.0 sharp

I notice that you're deleting the sharp module and running npm i again but the error message suggests that node_modules in the container still has a darwin-x64 compiled sharp

Can you attach to the container and check the node_modules directory once?

@sidharthachatterjee sidharthachatterjee added the status: needs more info Needs triaging and reproducible examples or more information to be resolved label Jan 16, 2019
@ettaibi
Copy link
Author

ettaibi commented Jan 17, 2019

correct @sidharthachatterjee here is my new Dockerfile

FROM node:10.12.0

WORKDIR /var/www


RUN npm install --quiet -g node-gyp gatsby-cli
# project node dependencies
COPY package.json /var/www/
RUN yarn install && yarn cache clean


# project files
COPY . /var/www/

and in docker-compose file I install sharp an gatsby-transformer-yaml from source, not sure yet if if --build-from-source works with yarn or yarn add is sufficent

version: '2.1'
services:
  app:
    build: .
    ports:
      - '8000:8000'
      - '9000:9000'
    volumes:
      - /var/www/node_modules
      - ./public:/var/www/public
    command: bash -c "yarn add sharp gatsby-transformer-yaml --build-from-source && yarn run build"
    env_file: .env

@ettaibi ettaibi closed this as completed Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs more info Needs triaging and reproducible examples or more information to be resolved type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

2 participants