watcher icon indicating copy to clipboard operation
watcher copied to clipboard

Docker build on MacOS M1: No native build was found for platform=linux arch=arm64

Open Richard87 opened this issue 2 years ago • 6 comments

🐛 bug report

Failed to run parcel build in docker on Apple M1 (natively).

🤔 Expected Behavior

Build should work

😯 Current Behavior

 Error: No native build was found for platform=linux arch=arm64 runtime=node abi=102 uv=1 armv=8 libc=glibc node=17.8.0
[builder 7/7] RUN cd /app && yarn run parcel build --cache-dir /.parcel-cache --public-url /build2:
parcel-bundler/parcel#11 0.214 yarn run v1.22.18
parcel-bundler/parcel#11 0.229 $ /app/node_modules/.bin/parcel build --cache-dir /.parcel-cache --public-url /build2
parcel-bundler/parcel#11 0.392 Error: No native build was found for platform=linux arch=arm64 runtime=node abi=102 uv=1 armv=8 libc=glibc node=17.8.0
parcel-bundler/parcel#11 0.392     loaded from: /app/node_modules/@parcel/watcher
parcel-bundler/parcel#11 0.392 
parcel-bundler/parcel#11 0.392     at Function.load.path (/app/node_modules/node-gyp-build/index.js:60:9)
parcel-bundler/parcel#11 0.392     at load (/app/node_modules/node-gyp-build/index.js:22:30)
parcel-bundler/parcel#11 0.392     at Object.<anonymous> (/app/node_modules/@parcel/watcher/index.js:1:104)
parcel-bundler/parcel#11 0.392     at Module._compile (/app/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
parcel-bundler/parcel#11 0.392     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
parcel-bundler/parcel#11 0.392     at Module.load (node:internal/modules/cjs/loader:975:32)
parcel-bundler/parcel#11 0.392     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
parcel-bundler/parcel#11 0.392     at Module.require (node:internal/modules/cjs/loader:999:19)
parcel-bundler/parcel#11 0.392     at require (/app/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
parcel-bundler/parcel#11 0.392     at Object.<anonymous> (/app/node_modules/@parcel/fs/lib/index.js:5:28)
parcel-bundler/parcel#11 0.513 error Command failed with exit code 1.
parcel-bundler/parcel#11 0.513 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
executor failed running [/bin/sh -c cd /app && yarn run parcel build --cache-dir /.parcel-cache --public-url /build2]: exit code: 1
➜  eportal git:(feature/folder-structure) ✗ 

💁 Possible Solution

No idea... :/

🔦 Context

Trying to build our docker container in native ARM, instead of x86/linux.

💻 Code Sample

Trying to build this container on M1:

FROM node:17 as builder
RUN mkdir -p /app
COPY frontend/package.json frontend/yarn.lock /app/
COPY frontend/tsconfig.json /app
# --mount=type=cache,id=npm-cache,target=/.npm-cache \
RUN cd /app && \
   npm config set "@fortawesome:registry" https://npm.fontawesome.com/ && \
   npm config set "//npm.fontawesome.com/:_authToken" && \
   yarn install --frozen-lockfile --ignore-scripts  --preferred-cache-folder /.npm-cache
COPY frontend/ /app/
RUN cd /app && yarn run parcel build --cache-dir /.parcel-cache --public-url /build2

🌍 Your Environment

Software Version(s)
Parcel 2.4.1
Node 17.8
npm/Yarn Yarn
Operating System Docker Desktop on MacOS M1 12.2.1

Richard87 avatar Apr 12 '22 20:04 Richard87

We'd need to add prebuilds for arm linux in the watcher module: https://github.com/parcel-bundler/watcher/blob/master/azure-pipelines.yml. Going to move this issue to that repo.

If you remove the --ignore-scripts option for yarn it should compile on install though.

devongovett avatar Apr 13 '22 15:04 devongovett

Ran into this as well using plain npm, wondering if there is a way to disable the watcher since for a Docker build there is no need for it I believe?

doronrosenberg avatar Apr 29 '22 01:04 doronrosenberg

We are also installing with --ignore-scripts, so I added this RUN-command after npm install:

RUN cd /app/node_modules/@parcel/watcher && yarn run node-gyp-build

Richard87 avatar May 01 '22 15:05 Richard87

We are also installing with --ignore-scripts, so I added this RUN-command after npm install:

RUN cd /app/node_modules/@parcel/watcher && yarn run node-gyp-build

There is no node-gyp-build in the parcel watcher package.json, am I missing something?

Switched to yarn:

FROM node:17 as node-build
WORKDIR /app
COPY ui/ .
RUN yarn install
RUN yarn run build

and that gets me:

[1/3] STEP 5/5: RUN yarn run build
yarn run v1.22.18
$ parcel build
[Error: std::bad_alloc]

doronrosenberg avatar May 02 '22 17:05 doronrosenberg

I realized I was copying over the old node_modules into docker. When I exclude node_modules and have yarn install things, I now end up with:

[1/3] STEP 5/5: RUN yarn run build
yarn run v1.22.18
$ parcel build
Error: Unable to deserialize cloned data due to invalid or unsupported version.
    at deserialize (node:v8:345:7)
    at deserialize (/app/node_modules/@parcel/core/lib/serializer.js:249:48)
    at loadRequestGraph (/app/node_modules/@parcel/core/lib/RequestTracker.js:854:52)
    at async Function.init (/app/node_modules/@parcel/core/lib/RequestTracker.js:821:17)
    at async Parcel._init (/app/node_modules/@parcel/core/lib/Parcel.js:256:28)
    at async Parcel.run (/app/node_modules/@parcel/core/lib/Parcel.js:273:7)
    at async run (/app/node_modules/parcel/lib/cli.js:374:7)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
Error: error building at STEP "RUN yarn run build": error while running runtime: exit status 1

I guess others have not run into that?

doronrosenberg avatar May 02 '22 18:05 doronrosenberg

I realized I was copying over the old node_modules into docker. When I exclude node_modules and have yarn install things, I now end up with:

[1/3] STEP 5/5: RUN yarn run build
yarn run v1.22.18
$ parcel build
Error: Unable to deserialize cloned data due to invalid or unsupported version.
    at deserialize (node:v8:345:7)
    at deserialize (/app/node_modules/@parcel/core/lib/serializer.js:249:48)
    at loadRequestGraph (/app/node_modules/@parcel/core/lib/RequestTracker.js:854:52)
    at async Function.init (/app/node_modules/@parcel/core/lib/RequestTracker.js:821:17)
    at async Parcel._init (/app/node_modules/@parcel/core/lib/Parcel.js:256:28)
    at async Parcel.run (/app/node_modules/@parcel/core/lib/Parcel.js:273:7)
    at async run (/app/node_modules/parcel/lib/cli.js:374:7)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
Error: error building at STEP "RUN yarn run build": error while running runtime: exit status 1

I guess others have not run into that?

To answer my own question - I had to remove .parcel-cache from the docker image as it was barfing on it.

doronrosenberg avatar May 02 '22 19:05 doronrosenberg

None of this is working. Tried below and its working now(FROM node:18.13.0-alpine):


  RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
  RUN python3 -m ensurepip
  RUN pip3 install --no-cache --upgrade pip setuptools
  RUN apk add --no-cache make
  RUN apk add gcc g++
  RUN yarn global add prebuild

RUN yarn install --ignore-scripts --frozen-lockfile

RUN cd /usr/src/app/node_modules/@parcel/watcher && yarn prebuild --openssl_fips=''

therepo90 avatar Feb 02 '23 13:02 therepo90

Should be resolved, once PR #132 is merged

felixgeissler avatar Jun 05 '23 11:06 felixgeissler

Ran into this as well using plain npm, wondering if there is a way to disable the watcher since for a Docker build there is no need for it I believe?

Any solution for this?

shivamsinghal212 avatar Jun 07 '23 15:06 shivamsinghal212

Waiting the release of the new version with PR https://github.com/parcel-bundler/watcher/pull/132 @devongovett to solve https://github.com/nrwl/nx-console/issues/1440#issuecomment-1535134708

guillempuche avatar Jun 09 '23 15:06 guillempuche

This should be fixed by #144 which includes prebuilds for more architectures. See the release notes for v2.2.0 for a full list.

devongovett avatar Jul 02 '23 03:07 devongovett