backstage: 🐛 Bug Report: docker build error on node-gyp rebuild with isolated-vm while yarn install phase
📜 Description
Hello Backstage community and team 😄
I’ve just upgraded backstage from 1.12.1 to 1.15.0 and my Docker build fails at
RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \ yarn install --frozen-lockfile --network-timeout 600000
with the multi-stage dockerfile of the current documentation.
Naturally it worked before upgrade.
I forced back “@backstage/plugin-scaffolder-backend”: “1.12.0” instead of “^1.15.0” in backend/package.json and it worked. And i presume it patch my problem because it’s the only plugin having “isolated-vm” as dependency.
👍 Expected behavior
It should build a docker image successfully.
👎 Actual Behavior with Screenshots
It fails at [5/5] Building fresh packages...
of the “yarn install” step, with the following crash log :
(“/opt/app-root/src/” is my Backstage workdir in the container)
[3/4] STEP 6/10: RUN yarn install --frozen-lockfile --cache-folder /home/node/.cache/yarn --network-timeout 600000 yarn install v1.22.19 [1/5] Validating package.json... [2/5] Resolving packages... [3/5] Fetching packages... warning Pattern ["app@link:packages/app"] is trying to unpack in the same destination "/home/node/.cache/yarn/v6/npm-app-0.0.0/node_modules/app" as pattern ["app@0.0.0","app@0.0.0"]. This could result in non-deterministic behavior, skipping. [4/5] Linking dependencies... warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @testing-library/user-event@14.4.3" has unmet peer dependency "@testing-library/dom@>=7.21.4". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > eslint-plugin-cypress@2.12.1" has unmet peer dependency "eslint@>= 3.2.1". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-scaffolder > @uiw/react-codemirror@4.19.4" has unmet peer dependency "@babel/runtime@>=7.11.0". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-scaffolder > @uiw/react-codemirror@4.19.4" has unmet peer dependency "@codemirror/state@>=6.0.0". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-scaffolder > @uiw/react-codemirror@4.19.4" has unmet peer dependency "@codemirror/theme-one-dark@>=6.0.0". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-scaffolder > @uiw/react-codemirror@4.19.4" has unmet peer dependency "codemirror@>=6.0.0". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-scaffolder > @backstage/plugin-scaffolder-react > @rjsf/material-ui-v5@5.7.3" has incorrect peer dependency "@rjsf/core@5.7.x". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-scaffolder > @uiw/react-codemirror > @uiw/codemirror-extensions-basic-setup@4.19.4" has unmet peer dependency "@codemirror/autocomplete@>=6.0.0". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-scaffolder > @uiw/react-codemirror > @uiw/codemirror-extensions-basic-setup@4.19.4" has unmet peer dependency "@codemirror/lint@>=6.0.0". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-scaffolder > @uiw/react-codemirror > @uiw/codemirror-extensions-basic-setup@4.19.4" has unmet peer dependency "@codemirror/search@>=6.0.0". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > backend > @backstage/plugin-techdocs-backend > @backstage/plugin-techdocs-node > @aws-sdk/lib-storage@3.354.0" has unmet peer dependency "@aws-sdk/abort-controller@^3.0.0". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-api-docs > graphiql > @graphiql/react > codemirror-graphql@1.3.2" has unmet peer dependency "@codemirror/language@^0.20.0". warning "workspace-aggregator-3a7436ed-a363-4a05-b68b-39c79596f0cd > app > @backstage/plugin-scaffolder > @uiw/react-codemirror > @uiw/codemirror-extensions-basic-setup > @codemirror/autocomplete@6.4.0" has unmet peer dependency "@lezer/common@^1.0.0". warning Workspaces can only be enabled in private projects. [5/5] Building fresh packages... info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. error /opt/app-root/src/node_modules/isolated-vm: Command failed. Exit code: 1 Command: node-gyp rebuild --release -j 4 Arguments: Directory: /opt/app-root/src/node_modules/isolated-vm Output: gyp info it worked if it ends with ok gyp info using node-gyp@9.3.1 gyp info using node@16.18.1 | linux | x64 gyp info find Python using Python version 3.6.8 found at "/usr/bin/python3" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args '/opt/app-root/src/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 '/opt/app-root/src/node_modules/isolated-vm/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/opt/app-root/src/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/opt/app-root/src/.cache/node-gyp/16.18.1/include/node/common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=/opt/app-root/src/.cache/node-gyp/16.18.1', gyp info spawn args '-Dnode_gyp_dir=/opt/app-root/src/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/opt/app-root/src/.cache/node-gyp/16.18.1/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/opt/app-root/src/node_modules/isolated-vm', 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=.' gyp info spawn args ] gyp info spawn make gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build', '--jobs', 4 ] make: Entering directory '/opt/app-root/src/node_modules/isolated-vm/build' CXX(target) Release/obj.target/nortti/src/external_copy/serializer_nortti.o CXX(target) Release/obj.target/nortti/src/isolate/allocator_nortti.o rm -f Release/obj.target/nortti.a Release/obj.target/nortti.a.ar-file-list; mkdir -p
dirname Release/obj.target/nortti.a`
ar crs Release/obj.target/nortti.a @Release/obj.target/nortti.a.ar-file-list
COPY Release/nortti.a
CXX(target) Release/obj.target/isolated_vm/src/external_copy/external_copy.o
CXX(target) Release/obj.target/isolated_vm/src/external_copy/serializer.o
CXX(target) Release/obj.target/isolated_vm/src/isolate/environment.o
CXX(target) Release/obj.target/isolated_vm/src/external_copy/string.o
…/src/isolate/environment.cc:34: warning: “_GNU_SOURCE” redefined
#define _GNU_SOURCE
<command-line>: note: this is the location of the previous definition
CXX(target) Release/obj.target/isolated_vm/src/isolate/cpu_profile_manager.o
CXX(target) Release/obj.target/isolated_vm/src/isolate/executor.o
CXX(target) Release/obj.target/isolated_vm/src/isolate/holder.o
CXX(target) Release/obj.target/isolated_vm/src/isolate/inspector.o
CXX(target) Release/obj.target/isolated_vm/src/isolate/platform_delegate.o
CXX(target) Release/obj.target/isolated_vm/src/isolate/scheduler.o
CXX(target) Release/obj.target/isolated_vm/src/isolate/stack_trace.o
CXX(target) Release/obj.target/isolated_vm/src/isolate/three_phase_task.o
CXX(target) Release/obj.target/isolated_vm/src/lib/thread_pool.o
CXX(target) Release/obj.target/isolated_vm/src/lib/timer.o
CXX(target) Release/obj.target/isolated_vm/src/module/callback.o
CXX(target) Release/obj.target/isolated_vm/src/module/context_handle.o
CXX(target) Release/obj.target/isolated_vm/src/module/evaluation.o
CXX(target) Release/obj.target/isolated_vm/src/module/external_copy_handle.o
CXX(target) Release/obj.target/isolated_vm/src/module/isolate.o
CXX(target) Release/obj.target/isolated_vm/src/module/isolate_handle.o
CXX(target) Release/obj.target/isolated_vm/src/module/lib_handle.o
CXX(target) Release/obj.target/isolated_vm/src/module/module_handle.o
…/src/module/lib_handle.cc: In member function ‘v8::Localv8::Value ivm::LibHandle::PrivateSymbol(v8::MaybeLocalv8::String)’:
…/src/module/lib_handle.cc:58:10: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
return reinterpret_cast<Local<Value>>(&symbol);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
…/src/module/lib_handle.cc:58:10: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
CXX(target) Release/obj.target/isolated_vm/src/module/native_module_handle.o
CXX(target) Release/obj.target/isolated_vm/src/module/reference_handle.o
CXX(target) Release/obj.target/isolated_vm/src/module/script_handle.o
CXX(target) Release/obj.target/isolated_vm/src/module/session_handle.o
CXX(target) Release/obj.target/isolated_vm/src/module/transferable.o
SOLINK_MODULE(target) Release/obj.target/isolated_vm.node
/usr/bin/ld: cannot find -lbrotlidec
/usr/bin/ld: cannot find -lbrotlienc
collect2: error: ld returned 1 exit status
make: *** [isolated_vm.target.mk:224: Release/obj.target/isolated_vm.node] Error 1
make: Leaving directory ‘/opt/app-root/src/node_modules/isolated-vm/build’
gyp ERR! build error
gyp ERR! stack Error: make
failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/opt/app-root/src/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Linux 3.10.0-1160.76.1.el7.x86_64
gyp ERR! command “/usr/bin/node” “/opt/app-root/src/node_modules/.bin/node-gyp” “rebuild” “–release” “-j” “4”
gyp ERR! cwd /opt/app-root/src/node_modules/isolated-vm
gyp ERR! node -v v16.18.1
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok
Error: error building at STEP “RUN yarn install --frozen-lockfile --cache-folder /home/node/.cache/yarn --network-timeout 600000”: error while running runtime: exit status 1
`
👟 Reproduction steps
It can be reproduced by creating a whole new project on 1.15.0 of Backstage. I’m using a Dockerfile very cloes to the multi-stage dockerfile of the current documentation, but any yarn install in docker env should fail (at least I tried to build this image in windows docker and in gitlab CI env and both failed). Then a docker build fails at mentionned step.
📃 Provide the context for the Bug.
No response
🖥️ Your Environment
My backend/package.json :
{ "name": "backend", "version": "0.0.0", "main": "dist/index.cjs.js", "types": "src/index.ts", "private": true, "backstage": { "role": "backend" }, "scripts": { "start": "backstage-cli package start", "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", "build-image": "docker build ../.. -f Dockerfile --tag backstage" }, "dependencies": { "@backstage/backend-common": "^0.19.0", "@backstage/backend-tasks": "^0.5.3", "@backstage/catalog-client": "^1.4.2", "@backstage/catalog-model": "^1.4.0", "@backstage/config": "^1.0.8", "@backstage/plugin-app-backend": "^0.3.46", "@backstage/plugin-auth-backend": "^0.18.4", "@backstage/plugin-auth-node": "^0.2.15", "@backstage/plugin-catalog-backend": "^1.10.0", "@backstage/plugin-catalog-backend-module-gitlab": "^0.2.2", "@backstage/plugin-catalog-backend-module-openapi": "^0.1.12", "@backstage/plugin-catalog-common": "^1.0.14", "@backstage/plugin-catalog-node": "^1.3.7", "@backstage/plugin-permission-common": "^0.7.6", "@backstage/plugin-permission-node": "^0.7.9", "@backstage/plugin-proxy-backend": "^0.2.40", "@backstage/plugin-scaffolder-backend": "^1.15.0", "@backstage/plugin-search-backend": "^1.3.2", "@backstage/plugin-search-backend-module-pg": "^0.5.7", "@backstage/plugin-search-backend-node": "^1.2.2", "@backstage/plugin-techdocs-backend": "^1.6.3", "app": "link:../app", "better-sqlite3": "^7.5.0", "dockerode": "^3.3.1", "express": "^4.17.1", "express-promise-router": "^4.1.0", "pg": "^8.3.0", "winston": "^3.2.1" }, "devDependencies": { "@backstage/cli": "^0.22.8", "@types/dockerode": "^3.3.0", "@types/express": "^4.17.6", "@types/express-serve-static-core": "^4.17.5", "@types/luxon": "^2.0.4" }, "files": [ "dist" ] }
👀 Have you spent some time to check if this bug has been raised before?
- I checked and didn’t find similar issue
🏢 Have you read the Code of Conduct?
- I have read the Code of Conduct
Are you willing to submit PR?
No, I don’t have time to work on this right now
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 3
- Comments: 38 (16 by maintainers)
@dweber019 Thanks! I just used
@backstage/create-app@latest
today and experienced this, and this is what fixed it.I added
yarn global add node-gyp
to the generated Dockerfile before the first install.Should this be re-opened?
This PR should resolve this newest iteration of this issue: https://github.com/backstage/backstage/pull/20695
I had the following issue:
In the second yarn install run (first was successful).
Solution was to install node-gyp globally because of
/bin/sh: 1: node-gyp: not found
.Just if some one as a similar issue 😉
@markstickley For my part I was on Openshift so I just switch to another node image
@awanlin not sure if we want to have a lighter dependency install in the dockerfile but a single install of “make” instead of “build-essentials” worked for me
@benjdlambert had the idea that in case the
yarn install
fails duringcreate-app
, we could check the log outputs to try to detect whetherisolated-vm
dependencies are missing, maybe even which ones. We could then directly provide feedback and instructions for how to install those deps, at least for some OS:es, and perhaps also link to docs.